@snaptrude/plugin-core 0.0.0-dev-20260911064951 → 0.0.0-surfaces-20260921090636

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.
Files changed (79) hide show
  1. package/CHANGELOG.md +0 -25
  2. package/api-manifest.json +151 -12
  3. package/dist/api/core/geom/create/index.d.ts +918 -93
  4. package/dist/api/core/geom/create/index.d.ts.map +1 -1
  5. package/dist/api/core/geom/query/brep.d.ts +50 -0
  6. package/dist/api/core/geom/query/brep.d.ts.map +1 -1
  7. package/dist/api/core/geom/query/curve.d.ts +58 -35
  8. package/dist/api/core/geom/query/curve.d.ts.map +1 -1
  9. package/dist/api/core/geom/query/edge.d.ts +2 -2
  10. package/dist/api/core/geom/query/face.d.ts +105 -0
  11. package/dist/api/core/geom/query/face.d.ts.map +1 -1
  12. package/dist/api/core/geom/update/curve.d.ts +5 -5
  13. package/dist/api/core/geom/update/profile.d.ts +1 -1
  14. package/dist/api/core/io/import/index.d.ts +1 -3
  15. package/dist/api/core/io/import/index.d.ts.map +1 -1
  16. package/dist/api/design/create/index.d.ts +22 -310
  17. package/dist/api/design/create/index.d.ts.map +1 -1
  18. package/dist/api/design/delete/index.d.ts +0 -4
  19. package/dist/api/design/delete/index.d.ts.map +1 -1
  20. package/dist/api/design/doors/index.d.ts +13 -20
  21. package/dist/api/design/doors/index.d.ts.map +1 -1
  22. package/dist/api/design/index.d.ts +0 -5
  23. package/dist/api/design/index.d.ts.map +1 -1
  24. package/dist/api/design/query/geometry/index.d.ts +27 -1
  25. package/dist/api/design/query/geometry/index.d.ts.map +1 -1
  26. package/dist/api/design/query/index.d.ts +47 -0
  27. package/dist/api/design/query/index.d.ts.map +1 -1
  28. package/dist/api/design/query/spaces.d.ts +5 -5
  29. package/dist/api/design/update/index.d.ts +87 -0
  30. package/dist/api/design/update/index.d.ts.map +1 -1
  31. package/dist/api/entity/referenceLine.d.ts +2 -2
  32. package/dist/api/entity/referenceLine.d.ts.map +1 -1
  33. package/dist/api/entity/space.d.ts +5 -4
  34. package/dist/api/entity/space.d.ts.map +1 -1
  35. package/dist/api/entity/story.d.ts +4 -4
  36. package/dist/api/presentation/annotate.d.ts +2 -2
  37. package/dist/api/presentation/shapes.d.ts +2 -2
  38. package/dist/api/program/site.d.ts +4 -4
  39. package/dist/api/program/spreadsheet.d.ts +4 -4
  40. package/dist/handles.d.ts +12 -22
  41. package/dist/handles.d.ts.map +1 -1
  42. package/dist/index.cjs +2773 -2445
  43. package/dist/index.cjs.map +1 -1
  44. package/dist/index.d.ts +2 -0
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +2726 -2422
  47. package/dist/index.js.map +1 -1
  48. package/dist/massParameters.d.ts +280 -0
  49. package/dist/massParameters.d.ts.map +1 -0
  50. package/dist/massParameters.ops.d.ts +135 -0
  51. package/dist/massParameters.ops.d.ts.map +1 -0
  52. package/package.json +1 -1
  53. package/src/api/core/geom/create/index.ts +1011 -94
  54. package/src/api/core/geom/query/brep.ts +51 -0
  55. package/src/api/core/geom/query/curve.ts +25 -2
  56. package/src/api/core/geom/query/edge.ts +2 -2
  57. package/src/api/core/geom/query/face.ts +109 -4
  58. package/src/api/core/io/import/index.ts +3 -11
  59. package/src/api/design/create/index.ts +38 -335
  60. package/src/api/design/delete/index.ts +0 -4
  61. package/src/api/design/doors/index.ts +13 -20
  62. package/src/api/design/index.ts +0 -5
  63. package/src/api/design/query/geometry/index.ts +29 -0
  64. package/src/api/design/query/index.ts +50 -0
  65. package/src/api/design/update/index.ts +94 -0
  66. package/src/handles.ts +15 -27
  67. package/src/index.ts +2 -0
  68. package/src/massParameters.ops.ts +243 -0
  69. package/src/massParameters.ts +418 -0
  70. package/test/massParameters.test.mjs +936 -0
  71. package/dist/api/design/create/bulk-items.d.ts +0 -185
  72. package/dist/api/design/create/bulk-items.d.ts.map +0 -1
  73. package/dist/api/design/create/opening-fields.d.ts +0 -37
  74. package/dist/api/design/create/opening-fields.d.ts.map +0 -1
  75. package/dist/api/design/dimensions.d.ts +0 -427
  76. package/dist/api/design/dimensions.d.ts.map +0 -1
  77. package/src/api/design/create/bulk-items.ts +0 -186
  78. package/src/api/design/create/opening-fields.ts +0 -37
  79. package/src/api/design/dimensions.ts +0 -453
@@ -174,6 +174,11 @@ export abstract class PluginGeomQueryBrepApi {
174
174
  * | `"line"` | `startPoint`, `endPoint`, `length` |
175
175
  * | `"arc"` | `startPoint`, `endPoint`, `centre`, `axis`, `radius`, `length` |
176
176
  * | `"circle"` | `centre`, `axis`, `radius`, `length` — a full-circle edge (e.g. a cylinder cap rim) |
177
+ * | `"spline"` | `startPoint`, `endPoint`, `degree`, `controlPoints`, `knots`, `length` — a free-form NURBS edge |
178
+ *
179
+ * For a `"spline"` edge, `knots` is the **expanded** knot vector — each knot
180
+ * repeated by its multiplicity, the textbook NURBS form — so
181
+ * `knots.length === controlPoints.length + degree + 1`.
177
182
  *
178
183
  * @param brep The brep the edge belongs to
179
184
  * @param edge The edge whose curve to read
@@ -184,6 +189,7 @@ export abstract class PluginGeomQueryBrepApi {
184
189
  * @examplePrompt Is this edge straight or an arc?
185
190
  * @examplePrompt Get the exact start and end points of this edge
186
191
  * @examplePrompt Measure the length of each edge of this mass
192
+ * @examplePrompt Read the control points of this curved edge
187
193
  *
188
194
  * # Example
189
195
  * ```ts
@@ -219,6 +225,16 @@ export abstract class PluginGeomQueryBrepApi {
219
225
  radius: number
220
226
  length: number
221
227
  }
228
+ | {
229
+ type: "spline"
230
+ startPoint: Vec3Components
231
+ endPoint: Vec3Components
232
+ degree: number
233
+ controlPoints: Vec3Components[]
234
+ /** Expanded by multiplicity: `controlPoints.length + degree + 1` entries. */
235
+ knots: number[]
236
+ length: number
237
+ }
222
238
  >
223
239
 
224
240
  /**
@@ -366,6 +382,37 @@ export abstract class PluginGeomQueryBrepApi {
366
382
  */
367
383
  public abstract getBoundingBox(brep: BrepHandle): PluginApiReturn<BBoxComponents>
368
384
 
385
+ /**
386
+ * Get the enclosed **volume** of a closed solid, integrated from its exact
387
+ * surfaces. Curved faces are measured analytically, not from their
388
+ * tessellation — a real sphere of radius 5 reports 523.6, whatever its
389
+ * triangle count. That makes this the reliable way to confirm a solid is the
390
+ * shape you intended (a torus should measure 2·π²·R·r²).
391
+ *
392
+ * Runs on the OpenCascade kernel (the first kernel call loads a wasm of tens
393
+ * of MB — expect a pause of seconds).
394
+ *
395
+ * @param brep The solid to measure
396
+ * @returns The enclosed volume in cubic raw Babylon units
397
+ * @throws OPERATION_FAILED if the kernel cannot compute the volume (the brep
398
+ * is not a closed solid)
399
+ *
400
+ * @examplePrompt What is the volume of this mass?
401
+ * @examplePrompt How much concrete is in this shape?
402
+ * @examplePrompt Check the volume of the dome I just made
403
+ *
404
+ * # Example
405
+ * ```ts
406
+ * const [mass] = await snaptrude.design.query.listMasses()
407
+ * const brep = await snaptrude.design.query.geometry.getBrep(mass)
408
+ * if (brep) {
409
+ * const volume = await snaptrude.core.geom.query.brep.getVolume(brep)
410
+ * console.log("volume:", volume)
411
+ * }
412
+ * ```
413
+ */
414
+ public abstract getVolume(brep: BrepHandle): PluginApiReturn<number>
415
+
369
416
  /**
370
417
  * Test whether two breps are geometrically equal.
371
418
  * @param brepA First brep
@@ -534,6 +581,10 @@ export type PluginGeomQueryBrepGetBoundingBoxArgs = z.infer<
534
581
  typeof PluginGeomQueryBrepGetBoundingBoxArgs
535
582
  >
536
583
 
584
+ /** Arguments for {@linkcode PluginGeomQueryBrepApi.getVolume}. `{ brep: BrepHandle }` */
585
+ export const PluginGeomQueryBrepGetVolumeArgs = brepArg
586
+ export type PluginGeomQueryBrepGetVolumeArgs = z.infer<typeof PluginGeomQueryBrepGetVolumeArgs>
587
+
537
588
  /**
538
589
  * Arguments for {@linkcode PluginGeomQueryBrepApi.isEqual}.
539
590
  *
@@ -3,8 +3,8 @@ import { PluginApiReturn } from "../../../../types"
3
3
  import { Vec3Handle, CurveHandle, LineHandle, Vec3Components } from "../../../../handles"
4
4
 
5
5
  /**
6
- * Curve queries — read-only geometric questions about curves (lines and arcs)
7
- * and the relationships between two curves (all-handle model, §11).
6
+ * Curve queries — read-only geometric questions about curves (lines, arcs and
7
+ * splines) and the relationships between two curves (all-handle model, §11).
8
8
  *
9
9
  * Every method takes opaque curve handles ({@linkcode CurveHandle}/{@linkcode LineHandle})
10
10
  * and point handles ({@linkcode Vec3Handle}) and returns plain values — points as
@@ -13,6 +13,29 @@ import { Vec3Handle, CurveHandle, LineHandle, Vec3Components } from "../../../..
13
13
  * {@linkcode CurveHandle} (or `null` when there is no result). No query mutates its
14
14
  * inputs.
15
15
  *
16
+ * ## Splines
17
+ *
18
+ * A {@linkcode CurveHandle} is a line, an arc, or a NURBS spline (minted by
19
+ * `core.geom.create.splineFromPoints`). Every method here accepts a spline at
20
+ * compile time, but only the reads backed by the engine's spline math answer
21
+ * for one today. The rest throw `PRECONDITION_FAILED` ("not supported for
22
+ * splines yet") — a typed refusal, never a quietly wrong answer.
23
+ *
24
+ * | Splines | Members |
25
+ * |---|---|
26
+ * | **supported** | {@linkcode PluginGeomQueryCurveApi.getStartPoint}, {@linkcode PluginGeomQueryCurveApi.getEndPoint}, {@linkcode PluginGeomQueryCurveApi.getLength}, {@linkcode PluginGeomQueryCurveApi.getTangent}, {@linkcode PluginGeomQueryCurveApi.listPoints}, {@linkcode PluginGeomQueryCurveApi.getNearestPoint} |
27
+ * | **not yet** | `getMidPoint`, `getChordLength`, `getNormal`, `getProjection`, `getPointAtDistance`, `getParameterAtPoint`, `getCurvature`, `getDistanceToPoint`, `getDistanceAlong`, `listSubdivisions`, `isLinear`, `isOnCurve`, `hasPoint`, `isEqual`, `isOverlapping`, `getCommonPart`, `listIntersections`, `getMergedCurve`, `isContinuous`, `isParallel`, `getShortestGap`, `getDistanceBetween` |
28
+ *
29
+ * {@linkcode PluginGeomQueryCurveApi.isOverlapping} is deliberately in the
30
+ * second row: its line/arc path falls back to structural equality, which would
31
+ * answer a spline pair wrongly rather than not at all.
32
+ *
33
+ * To work around the second row, sample the curve —
34
+ * {@linkcode PluginGeomQueryCurveApi.listPoints} then the ordinary
35
+ * `core.math.vec3` operations — or read a spline brep edge exactly with
36
+ * `core.geom.query.brep.getEdgeCurve`, which returns its degree, control points
37
+ * and knots.
38
+ *
16
39
  * Accessed via `snaptrude.core.geom.query.curve`.
17
40
  */
18
41
  export abstract class PluginGeomQueryCurveApi {
@@ -69,9 +69,9 @@ export abstract class PluginGeomQueryEdgeApi {
69
69
  public abstract listVertices(edge: EdgeHandle): PluginApiReturn<VertexHandle[]>
70
70
 
71
71
  /**
72
- * Get the underlying curve geometry of an edge (a line or arc).
72
+ * Get the underlying curve geometry of an edge (a line, arc or spline).
73
73
  * @param edge The edge to query
74
- * @returns The curve as a {@linkcode CurveHandle}, or `null` if it is a circle or unset
74
+ * @returns The curve as a {@linkcode CurveHandle} (`line_`, `arc_` or `spline_`), or `null` if it is a circle or unset
75
75
  *
76
76
  * # Example
77
77
  * ```ts
@@ -59,6 +59,49 @@ export abstract class PluginGeomQueryFaceApi {
59
59
  */
60
60
  public abstract getMaterialIndex(face: FaceHandle): PluginApiReturn<number>
61
61
 
62
+ /**
63
+ * Read what KIND of surface a face lies on. This is the one read that tells a
64
+ * genuinely curved face from a faceted approximation of one: every face of a
65
+ * 200-triangle "dome" answers `"plane"`, while a real dome has faces
66
+ * answering `"sphere"`. Use it to confirm a curved solid actually came out
67
+ * curved.
68
+ *
69
+ * | Value | Surface |
70
+ * |---|---|
71
+ * | `"plane"` | Flat face |
72
+ * | `"cylinder"` | Cylindrical face — constant radius about an axis |
73
+ * | `"cone"` | Conical face — a tapered ring (a cone or frustum side) |
74
+ * | `"sphere"` | Spherical face |
75
+ * | `"torus"` | Toroidal face — the ring surface of a donut |
76
+ * | `"spline"` | Free-form NURBS face |
77
+ *
78
+ * Pure read: no geometry kernel is loaded.
79
+ *
80
+ * @param face The face to query
81
+ * @returns The surface kind (see the table), or `null` when the face carries
82
+ * no surface classification
83
+ *
84
+ * @examplePrompt Is this face flat or curved?
85
+ * @examplePrompt Check that this dome is a real sphere, not a faceted approximation
86
+ * @examplePrompt What kind of surface is this face?
87
+ * @examplePrompt How many curved faces does this mass have?
88
+ *
89
+ * # Example
90
+ * ```ts
91
+ * const [mass] = await snaptrude.design.query.listMasses()
92
+ * const brep = await snaptrude.design.query.geometry.getBrep(mass)
93
+ * if (brep) {
94
+ * const faces = await snaptrude.core.geom.query.brep.listFaces(brep)
95
+ * const kinds = []
96
+ * for (const face of faces) kinds.push(await snaptrude.core.geom.query.face.getSurfaceKind(face))
97
+ * console.log("spherical faces:", kinds.filter((k) => k === "sphere").length)
98
+ * }
99
+ * ```
100
+ */
101
+ public abstract getSurfaceKind(
102
+ face: FaceHandle,
103
+ ): PluginApiReturn<"plane" | "cylinder" | "cone" | "sphere" | "torus" | "spline" | null>
104
+
62
105
  /**
63
106
  * Get a seed half-edge of a face's outer loop.
64
107
  * @param face The face to query
@@ -257,6 +300,56 @@ export abstract class PluginGeomQueryFaceApi {
257
300
  brep: BrepHandle,
258
301
  ): PluginApiReturn<Vec3Components[]>
259
302
 
303
+ /**
304
+ * Exact surface area of one face of `brep`, in internal length units SQUARED —
305
+ * integrated off the face's own surface, not its facets, so a curved patch
306
+ * reads exactly rather than as its triangles. Needs the parent brep: a face
307
+ * handle cannot name its own solid.
308
+ * @param face The face to measure
309
+ * @param brep The parent brep (owner last, as in
310
+ * {@linkcode PluginGeomQueryFaceApi.listVertexPositions})
311
+ * @returns The area as a `number`
312
+ * @throws VALIDATION if `face` is not a face of `brep`
313
+ * @throws OPERATION_FAILED if the kernel could not measure the face
314
+ *
315
+ * @examplePrompt How big is this roof patch?
316
+ * @examplePrompt Which face of this mass has the largest area?
317
+ *
318
+ * # Example
319
+ * ```ts
320
+ * const [mass] = await snaptrude.design.query.listMasses()
321
+ * const brep = await snaptrude.design.query.geometry.getBrep(mass)
322
+ * if (brep) {
323
+ * const faces = await snaptrude.core.geom.query.brep.listFaces(brep)
324
+ * const areas = await Promise.all(
325
+ * faces.map((f) => snaptrude.core.geom.query.face.getArea(f, brep)),
326
+ * )
327
+ * }
328
+ * ```
329
+ */
330
+ public abstract getArea(face: FaceHandle, brep: BrepHandle): PluginApiReturn<number>
331
+
332
+ /**
333
+ * Centre of area of one face of `brep`, as a point in that brep's frame
334
+ * (internal length units). On a solid whose every face reads `"spline"` this
335
+ * is the read that tells two patches apart — the top of a thickened patch from
336
+ * its bottom, one quarter of a closed surface from the next.
337
+ * @param face The face to measure
338
+ * @param brep The parent brep (owner last)
339
+ * @returns The centroid as {@linkcode Vec3Components}
340
+ * @throws VALIDATION if `face` is not a face of `brep`
341
+ * @throws OPERATION_FAILED if the kernel could not measure the face
342
+ *
343
+ * @examplePrompt Where is the middle of this face?
344
+ * @examplePrompt Pick the topmost face of this curved mass
345
+ *
346
+ * # Example
347
+ * ```ts
348
+ * const centre = await snaptrude.core.geom.query.face.getCentroid(face, brep)
349
+ * ```
350
+ */
351
+ public abstract getCentroid(face: FaceHandle, brep: BrepHandle): PluginApiReturn<Vec3Components>
352
+
260
353
  /**
261
354
  * List the tessellated boundary points of a face's outer loop (arcs sampled,
262
355
  * sense-corrected). Not cardinality-equal to {@linkcode PluginGeomQueryFaceApi.listVertexPositions}.
@@ -301,6 +394,7 @@ export abstract class PluginGeomQueryFaceApi {
301
394
  }
302
395
 
303
396
  const faceArg = z.object({ face: FaceHandle })
397
+ const faceWithBrepArg = z.object({ face: FaceHandle, brep: BrepHandle })
304
398
 
305
399
  /** Arguments for {@linkcode PluginGeomQueryFaceApi.getIndex}. `{ face: FaceHandle }` */
306
400
  export const PluginGeomQueryFaceGetIndexArgs = faceArg
@@ -312,6 +406,12 @@ export type PluginGeomQueryFaceGetMaterialIndexArgs = z.infer<
312
406
  typeof PluginGeomQueryFaceGetMaterialIndexArgs
313
407
  >
314
408
 
409
+ /** Arguments for {@linkcode PluginGeomQueryFaceApi.getSurfaceKind}. `{ face: FaceHandle }` */
410
+ export const PluginGeomQueryFaceGetSurfaceKindArgs = faceArg
411
+ export type PluginGeomQueryFaceGetSurfaceKindArgs = z.infer<
412
+ typeof PluginGeomQueryFaceGetSurfaceKindArgs
413
+ >
414
+
315
415
  /** Arguments for {@linkcode PluginGeomQueryFaceApi.getHalfEdge}. `{ face: FaceHandle }` */
316
416
  export const PluginGeomQueryFaceGetHalfEdgeArgs = faceArg
317
417
  export type PluginGeomQueryFaceGetHalfEdgeArgs = z.infer<typeof PluginGeomQueryFaceGetHalfEdgeArgs>
@@ -382,14 +482,19 @@ export type PluginGeomQueryFaceGetHoleContainingHalfEdgeArgs = z.infer<
382
482
  * | `face` | {@linkcode FaceHandle} | The face to query |
383
483
  * | `brep` | {@linkcode BrepHandle} | The parent brep (source of vertex coordinates) |
384
484
  */
385
- export const PluginGeomQueryFaceListVertexPositionsArgs = z.object({
386
- face: FaceHandle,
387
- brep: BrepHandle,
388
- })
485
+ export const PluginGeomQueryFaceListVertexPositionsArgs = faceWithBrepArg
389
486
  export type PluginGeomQueryFaceListVertexPositionsArgs = z.infer<
390
487
  typeof PluginGeomQueryFaceListVertexPositionsArgs
391
488
  >
392
489
 
490
+ /** Arguments for {@linkcode PluginGeomQueryFaceApi.getArea}. `{ face: FaceHandle, brep: BrepHandle }` */
491
+ export const PluginGeomQueryFaceGetAreaArgs = faceWithBrepArg
492
+ export type PluginGeomQueryFaceGetAreaArgs = z.infer<typeof PluginGeomQueryFaceGetAreaArgs>
493
+
494
+ /** Arguments for {@linkcode PluginGeomQueryFaceApi.getCentroid}. `{ face: FaceHandle, brep: BrepHandle }` */
495
+ export const PluginGeomQueryFaceGetCentroidArgs = faceWithBrepArg
496
+ export type PluginGeomQueryFaceGetCentroidArgs = z.infer<typeof PluginGeomQueryFaceGetCentroidArgs>
497
+
393
498
  /** Arguments for {@linkcode PluginGeomQueryFaceApi.listVertexPositionsWithCurves}. `{ face: FaceHandle }` */
394
499
  export const PluginGeomQueryFaceListVertexPositionsWithCurvesArgs = faceArg
395
500
  export type PluginGeomQueryFaceListVertexPositionsWithCurvesArgs = z.infer<
@@ -183,10 +183,7 @@ export abstract class PluginCoreIoImportApi {
183
183
  * if (cad) console.log("DWG imported as CAD underlay:", cad)
184
184
  * ```
185
185
  */
186
- public abstract dwg(
187
- source: string,
188
- storey?: number,
189
- ): PluginApiReturn<ImportJobHandle>
186
+ public abstract dwg(source: string, storey?: number): PluginApiReturn<ImportJobHandle>
190
187
 
191
188
  /**
192
189
  * Sketch a CAD underlay from **already-parsed CAD JSON** — synchronous, with no
@@ -217,10 +214,7 @@ export abstract class PluginCoreIoImportApi {
217
214
  * )
218
215
  * ```
219
216
  */
220
- public abstract cadJson(
221
- cad: CadJsonInput,
222
- storey?: number,
223
- ): PluginApiReturn<UnderlayHandle>
217
+ public abstract cadJson(cad: CadJsonInput, storey?: number): PluginApiReturn<UnderlayHandle>
224
218
 
225
219
  /**
226
220
  * Import a **3D model** file and place it in the scene as a component.
@@ -245,9 +239,7 @@ export abstract class PluginCoreIoImportApi {
245
239
  * @returns the placed {@linkcode ComponentHandle}.
246
240
  * @throws if writes are disabled, the source can't be loaded, the format is
247
241
  * unsupported, conversion/placement fails, or the converted model cannot be
248
- * found in the library after upload; `PRECONDITION_FAILED`
249
- * (`details.engineCode: "TOOL_ACTIVE"`) while the interactive furniture tool is
250
- * active — finish or cancel it first.
242
+ * found in the library after upload.
251
243
  *
252
244
  * @examplePrompt Import this SketchUp model onto storey 1
253
245
  * @examplePrompt Bring in this OBJ file and place it at the origin