@snaptrude/plugin-core 0.9.16 → 0.9.18-edgesetbacks-20261021.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.
Files changed (221) hide show
  1. package/AGENTS.md +231 -231
  2. package/CHANGELOG.md +408 -402
  3. package/CLAUDE.md +11 -11
  4. package/api-manifest.json +1510 -701
  5. package/dist/api/analysis/daylight.d.ts +5 -5
  6. package/dist/api/analysis/solar.d.ts +2 -2
  7. package/dist/api/core/camera/index.d.ts +29 -0
  8. package/dist/api/core/camera/index.d.ts.map +1 -1
  9. package/dist/api/core/geom/create/index.d.ts +7 -1
  10. package/dist/api/core/geom/create/index.d.ts.map +1 -1
  11. package/dist/api/core/geom/update/contour.d.ts +8 -2
  12. package/dist/api/core/geom/update/contour.d.ts.map +1 -1
  13. package/dist/api/core/storeys/index.d.ts +5 -2
  14. package/dist/api/core/storeys/index.d.ts.map +1 -1
  15. package/dist/api/core/zoom/index.d.ts +13 -0
  16. package/dist/api/core/zoom/index.d.ts.map +1 -1
  17. package/dist/api/design/bim.d.ts +299 -0
  18. package/dist/api/design/bim.d.ts.map +1 -0
  19. package/dist/api/design/boolean/index.d.ts +2 -0
  20. package/dist/api/design/boolean/index.d.ts.map +1 -1
  21. package/dist/api/design/catalog.d.ts +320 -0
  22. package/dist/api/design/catalog.d.ts.map +1 -0
  23. package/dist/api/design/create/bulk-items.d.ts +65 -25
  24. package/dist/api/design/create/bulk-items.d.ts.map +1 -1
  25. package/dist/api/design/create/index.d.ts +299 -100
  26. package/dist/api/design/create/index.d.ts.map +1 -1
  27. package/dist/api/design/create/opening-fields.d.ts +13 -12
  28. package/dist/api/design/create/opening-fields.d.ts.map +1 -1
  29. package/dist/api/design/delete/index.d.ts +1 -0
  30. package/dist/api/design/delete/index.d.ts.map +1 -1
  31. package/dist/api/design/doors/index.d.ts +18 -24
  32. package/dist/api/design/doors/index.d.ts.map +1 -1
  33. package/dist/api/design/family.d.ts +813 -35
  34. package/dist/api/design/family.d.ts.map +1 -1
  35. package/dist/api/design/index.d.ts +16 -0
  36. package/dist/api/design/index.d.ts.map +1 -1
  37. package/dist/api/design/networks.d.ts +1703 -0
  38. package/dist/api/design/networks.d.ts.map +1 -0
  39. package/dist/api/design/query/grids.d.ts +2 -2
  40. package/dist/api/design/query/index.d.ts +42 -32
  41. package/dist/api/design/query/index.d.ts.map +1 -1
  42. package/dist/api/design/selection/index.d.ts +10 -10
  43. package/dist/api/design/types/index.d.ts +40 -24
  44. package/dist/api/design/types/index.d.ts.map +1 -1
  45. package/dist/api/design/update/index.d.ts +111 -6
  46. package/dist/api/design/update/index.d.ts.map +1 -1
  47. package/dist/api/design/windows/index.d.ts +8 -8
  48. package/dist/api/design/windows/index.d.ts.map +1 -1
  49. package/dist/api/entity/buildableEnvelope.d.ts +84 -2
  50. package/dist/api/entity/buildableEnvelope.d.ts.map +1 -1
  51. package/dist/api/presentation/aiInspiration.d.ts +10 -10
  52. package/dist/api/presentation/annotate.d.ts +38 -22
  53. package/dist/api/presentation/annotate.d.ts.map +1 -1
  54. package/dist/api/presentation/drawingContract.d.ts +32 -0
  55. package/dist/api/presentation/drawingContract.d.ts.map +1 -0
  56. package/dist/api/presentation/drawings.d.ts +3523 -0
  57. package/dist/api/presentation/drawings.d.ts.map +1 -0
  58. package/dist/api/presentation/export.d.ts +23 -5
  59. package/dist/api/presentation/export.d.ts.map +1 -1
  60. package/dist/api/presentation/index.d.ts +41 -12
  61. package/dist/api/presentation/index.d.ts.map +1 -1
  62. package/dist/api/presentation/placedViews.d.ts +106 -6
  63. package/dist/api/presentation/placedViews.d.ts.map +1 -1
  64. package/dist/api/presentation/sections.d.ts +461 -0
  65. package/dist/api/presentation/sections.d.ts.map +1 -0
  66. package/dist/api/presentation/shapes.d.ts +2 -2
  67. package/dist/api/presentation/sheets.d.ts +175 -19
  68. package/dist/api/presentation/sheets.d.ts.map +1 -1
  69. package/dist/api/presentation/viewPresets.d.ts +222 -0
  70. package/dist/api/presentation/viewPresets.d.ts.map +1 -0
  71. package/dist/api/presentation/views.d.ts +141 -8
  72. package/dist/api/presentation/views.d.ts.map +1 -1
  73. package/dist/api/presentation/walkthroughs.d.ts +6 -6
  74. package/dist/errors/codes.d.ts +3 -1
  75. package/dist/errors/codes.d.ts.map +1 -1
  76. package/dist/index.cjs +3883 -2385
  77. package/dist/index.cjs.map +1 -1
  78. package/dist/index.js +3744 -2385
  79. package/dist/index.js.map +1 -1
  80. package/package.json +1 -1
  81. package/scripts/check-dist-fresh.mjs +22 -22
  82. package/scripts/generate-manifest.mjs +243 -238
  83. package/scripts/generate-manifest.test.mjs +303 -303
  84. package/src/api/analysis/daylight.ts +470 -470
  85. package/src/api/analysis/heatmaps.ts +683 -683
  86. package/src/api/analysis/illuminance.ts +155 -155
  87. package/src/api/analysis/index.ts +61 -61
  88. package/src/api/analysis/shadows.ts +183 -183
  89. package/src/api/analysis/solar.ts +237 -237
  90. package/src/api/analysis/sunlightHours.ts +211 -211
  91. package/src/api/analysis/sunpath.ts +83 -83
  92. package/src/api/analysis/weather.ts +179 -179
  93. package/src/api/core/buildings.ts +485 -485
  94. package/src/api/core/camera/index.ts +696 -667
  95. package/src/api/core/comment/index.ts +376 -376
  96. package/src/api/core/geom/create/index.ts +2139 -2133
  97. package/src/api/core/geom/delete/index.ts +84 -84
  98. package/src/api/core/geom/index.ts +35 -35
  99. package/src/api/core/geom/query/arc.ts +169 -169
  100. package/src/api/core/geom/query/brep.ts +621 -621
  101. package/src/api/core/geom/query/circle.ts +404 -404
  102. package/src/api/core/geom/query/contour.ts +540 -540
  103. package/src/api/core/geom/query/curve.ts +1102 -1102
  104. package/src/api/core/geom/query/edge.ts +130 -130
  105. package/src/api/core/geom/query/face.ts +508 -508
  106. package/src/api/core/geom/query/halfedge.ts +210 -210
  107. package/src/api/core/geom/query/index.ts +63 -63
  108. package/src/api/core/geom/query/profile.ts +473 -473
  109. package/src/api/core/geom/query/vertex.ts +205 -205
  110. package/src/api/core/geom/update/contour.ts +323 -317
  111. package/src/api/core/geom/update/curve.ts +209 -209
  112. package/src/api/core/geom/update/index.ts +29 -29
  113. package/src/api/core/geom/update/profile.ts +379 -379
  114. package/src/api/core/groups.ts +521 -521
  115. package/src/api/core/handles/index.ts +234 -234
  116. package/src/api/core/history/index.ts +84 -84
  117. package/src/api/core/index.ts +99 -99
  118. package/src/api/core/io/export/index.ts +126 -126
  119. package/src/api/core/io/import/index.ts +504 -504
  120. package/src/api/core/io/index.ts +42 -42
  121. package/src/api/core/io/job/index.ts +140 -140
  122. package/src/api/core/io/query/index.ts +71 -71
  123. package/src/api/core/io/terrain/index.ts +360 -360
  124. package/src/api/core/io/underlay/index.ts +705 -705
  125. package/src/api/core/layers.ts +540 -540
  126. package/src/api/core/math/index.ts +20 -20
  127. package/src/api/core/math/quat.ts +172 -172
  128. package/src/api/core/math/vec3.ts +179 -179
  129. package/src/api/core/mode/index.ts +108 -108
  130. package/src/api/core/project/index.ts +479 -479
  131. package/src/api/core/proposals/index.ts +570 -570
  132. package/src/api/core/storeys/index.ts +311 -308
  133. package/src/api/core/storeys/layers.ts +339 -339
  134. package/src/api/core/tags.ts +911 -911
  135. package/src/api/core/units/index.ts +164 -164
  136. package/src/api/core/user.ts +46 -46
  137. package/src/api/core/zoom/index.ts +64 -51
  138. package/src/api/design/bim.ts +210 -0
  139. package/src/api/design/boolean/index.ts +181 -179
  140. package/src/api/design/catalog.ts +203 -0
  141. package/src/api/design/create/bulk-items.ts +294 -254
  142. package/src/api/design/create/grids.ts +137 -137
  143. package/src/api/design/create/index.ts +2178 -1980
  144. package/src/api/design/create/opening-fields.ts +40 -37
  145. package/src/api/design/delete/index.ts +75 -74
  146. package/src/api/design/dimensions.ts +453 -453
  147. package/src/api/design/doors/index.ts +516 -500
  148. package/src/api/design/edit/index.ts +54 -54
  149. package/src/api/design/erase/index.ts +151 -151
  150. package/src/api/design/family.ts +1342 -704
  151. package/src/api/design/furniture/index.ts +319 -319
  152. package/src/api/design/grids.ts +237 -237
  153. package/src/api/design/index.ts +304 -274
  154. package/src/api/design/lock.ts +69 -69
  155. package/src/api/design/materials/index.ts +608 -608
  156. package/src/api/design/networks.ts +607 -0
  157. package/src/api/design/query/geometry/index.ts +319 -319
  158. package/src/api/design/query/grids.ts +197 -197
  159. package/src/api/design/query/index.ts +1236 -1226
  160. package/src/api/design/query/referenceLines.ts +52 -52
  161. package/src/api/design/query/spaces.ts +275 -275
  162. package/src/api/design/selection/index.ts +273 -273
  163. package/src/api/design/shared.ts +40 -40
  164. package/src/api/design/transform/index.ts +254 -254
  165. package/src/api/design/types/index.ts +163 -156
  166. package/src/api/design/update/index.ts +1096 -983
  167. package/src/api/design/visibility.ts +143 -143
  168. package/src/api/design/windows/index.ts +351 -333
  169. package/src/api/entity/buildableEnvelope.ts +397 -322
  170. package/src/api/entity/index.ts +30 -30
  171. package/src/api/entity/referenceLine.ts +235 -235
  172. package/src/api/entity/space.ts +612 -612
  173. package/src/api/entity/story.ts +517 -517
  174. package/src/api/index.ts +47 -47
  175. package/src/api/presentation/aiInspiration.ts +1116 -1116
  176. package/src/api/presentation/annotate.ts +417 -385
  177. package/src/api/presentation/camera.ts +289 -289
  178. package/src/api/presentation/diagrams.ts +194 -194
  179. package/src/api/presentation/drawingContract.ts +70 -0
  180. package/src/api/presentation/drawings.ts +1179 -0
  181. package/src/api/presentation/export.ts +134 -108
  182. package/src/api/presentation/import.ts +159 -159
  183. package/src/api/presentation/index.ts +160 -126
  184. package/src/api/presentation/placedViews.ts +1211 -1120
  185. package/src/api/presentation/sections.ts +420 -0
  186. package/src/api/presentation/shapes.ts +274 -274
  187. package/src/api/presentation/sheets.ts +746 -585
  188. package/src/api/presentation/slideshow.ts +134 -134
  189. package/src/api/presentation/tables.ts +84 -84
  190. package/src/api/presentation/viewPresets.ts +241 -0
  191. package/src/api/presentation/views.ts +742 -673
  192. package/src/api/presentation/walkthroughs.ts +1201 -1201
  193. package/src/api/program/adjacency.ts +164 -164
  194. package/src/api/program/areas.ts +408 -408
  195. package/src/api/program/classification.ts +138 -138
  196. package/src/api/program/cores.ts +83 -83
  197. package/src/api/program/departments.ts +517 -517
  198. package/src/api/program/index.ts +73 -73
  199. package/src/api/program/labels.ts +332 -332
  200. package/src/api/program/layout.ts +422 -422
  201. package/src/api/program/metadata.ts +364 -364
  202. package/src/api/program/metrics.ts +120 -120
  203. package/src/api/program/site.ts +748 -748
  204. package/src/api/program/spreadsheet.ts +2698 -2698
  205. package/src/api/workspace/index.ts +612 -612
  206. package/src/errors/codes.ts +143 -136
  207. package/src/errors/envelope.ts +75 -75
  208. package/src/errors/index.ts +21 -21
  209. package/src/errors/plugin-error.ts +134 -134
  210. package/src/handles.ts +297 -297
  211. package/src/host-utils.ts +67 -67
  212. package/src/index.ts +7 -7
  213. package/src/massParameters.ops.ts +246 -246
  214. package/src/massParameters.ts +427 -427
  215. package/src/types.ts +16 -16
  216. package/test/drawingContract.test.mjs +288 -0
  217. package/test/errors.test.mjs +185 -184
  218. package/test/massParameters.test.mjs +952 -952
  219. package/test/presentationViewSettings.test.mjs +85 -0
  220. package/tsconfig.json +22 -22
  221. package/tsup.config.ts +12 -12
@@ -1,621 +1,621 @@
1
- import * as z from "zod"
2
- import { PluginApiReturn } from "../../../../types"
3
- import {
4
- BrepHandle,
5
- FaceHandle,
6
- EdgeHandle,
7
- VertexHandle,
8
- HalfEdgeHandle,
9
- Vec3Components,
10
- BBoxComponents,
11
- } from "../../../../handles"
12
-
13
- /**
14
- * BREP queries — read the topology and geometry of a boundary-representation mesh
15
- * as plain values / child handles (all-handle model, §11). A {@linkcode BrepHandle}
16
- * is a session-ephemeral resource handle obtained from `design.query.geometry.getBrep`;
17
- * it goes stale on undo/redo/re-topologize.
18
- *
19
- * Enumerations mint fresh child topology handles ({@linkcode FaceHandle},
20
- * {@linkcode EdgeHandle}, {@linkcode VertexHandle}, {@linkcode HalfEdgeHandle}); the
21
- * registry dedupes by identity, so re-enumeration returns the same handles. Position
22
- * reads return {@linkcode Vec3Components}. No query mutates its inputs.
23
- *
24
- * Accessed via `snaptrude.core.geom.query.brep`.
25
- */
26
- export abstract class PluginGeomQueryBrepApi {
27
- constructor() {}
28
-
29
- /**
30
- * List the faces of a brep.
31
- * @param brep The brep to query
32
- * @returns The faces as {@linkcode FaceHandle}`[]`
33
- *
34
- * # Example
35
- * ```ts
36
- * const [wall] = await snaptrude.design.query.listWalls()
37
- * const brep = await snaptrude.design.query.geometry.getBrep(wall)
38
- * if (brep) {
39
- * const faces = await snaptrude.core.geom.query.brep.listFaces(brep)
40
- * }
41
- * ```
42
- */
43
- public abstract listFaces(brep: BrepHandle): PluginApiReturn<FaceHandle[]>
44
-
45
- /**
46
- * List the edges of a brep.
47
- * @param brep The brep to query
48
- * @returns The edges as {@linkcode EdgeHandle}`[]`
49
- *
50
- * # Example
51
- * ```ts
52
- * const [wall] = await snaptrude.design.query.listWalls()
53
- * const brep = await snaptrude.design.query.geometry.getBrep(wall)
54
- * if (brep) {
55
- * const edges = await snaptrude.core.geom.query.brep.listEdges(brep)
56
- * }
57
- * ```
58
- */
59
- public abstract listEdges(brep: BrepHandle): PluginApiReturn<EdgeHandle[]>
60
-
61
- /**
62
- * List the vertices of a brep.
63
- * @param brep The brep to query
64
- * @returns The vertices as {@linkcode VertexHandle}`[]`
65
- *
66
- * # Example
67
- * ```ts
68
- * const [mass] = await snaptrude.design.query.listMasses()
69
- * const brep = await snaptrude.design.query.geometry.getBrep(mass)
70
- * if (brep) {
71
- * const vertices = await snaptrude.core.geom.query.brep.listVertices(brep)
72
- * }
73
- * ```
74
- */
75
- public abstract listVertices(brep: BrepHandle): PluginApiReturn<VertexHandle[]>
76
-
77
- /**
78
- * List the half-edges of a brep.
79
- * @param brep The brep to query
80
- * @returns The half-edges as {@linkcode HalfEdgeHandle}`[]`
81
- *
82
- * # Example
83
- * ```ts
84
- * const [wall] = await snaptrude.design.query.listWalls()
85
- * const brep = await snaptrude.design.query.geometry.getBrep(wall)
86
- * if (brep) {
87
- * const halfEdges = await snaptrude.core.geom.query.brep.listHalfEdges(brep)
88
- * }
89
- * ```
90
- */
91
- public abstract listHalfEdges(brep: BrepHandle): PluginApiReturn<HalfEdgeHandle[]>
92
-
93
- /**
94
- * Get the edge connecting two vertices (by their brep vertex indices).
95
- * @param brep The brep to query
96
- * @param vertexIndexA First vertex index
97
- * @param vertexIndexB Second vertex index
98
- * @returns The edge as an {@linkcode EdgeHandle}, or `null` if no such edge exists
99
- *
100
- * # Example
101
- * ```ts
102
- * const [wall] = await snaptrude.design.query.listWalls()
103
- * const brep = await snaptrude.design.query.geometry.getBrep(wall)
104
- * if (brep) {
105
- * const [va, vb] = await snaptrude.core.geom.query.brep.listVertices(brep)
106
- * const ia = await snaptrude.core.geom.query.vertex.getIndex(va)
107
- * const ib = await snaptrude.core.geom.query.vertex.getIndex(vb)
108
- * const edge = await snaptrude.core.geom.query.brep.getEdge(brep, ia, ib)
109
- * if (edge) console.log("those two vertices are connected")
110
- * }
111
- * ```
112
- */
113
- public abstract getEdge(
114
- brep: BrepHandle,
115
- vertexIndexA: number,
116
- vertexIndexB: number
117
- ): PluginApiReturn<EdgeHandle | null>
118
-
119
- /**
120
- * Test whether an edge connects two vertices (by their brep vertex indices).
121
- * @param brep The brep to query
122
- * @param vertexIndexA First vertex index
123
- * @param vertexIndexB Second vertex index
124
- * @returns `true` if such an edge exists, otherwise `false`
125
- *
126
- * # Example
127
- * ```ts
128
- * const [wall] = await snaptrude.design.query.listWalls()
129
- * const brep = await snaptrude.design.query.geometry.getBrep(wall)
130
- * if (brep) {
131
- * // brep vertex indices (get one from core.geom.query.vertex.getIndex)
132
- * const connected = await snaptrude.core.geom.query.brep.hasEdge(brep, 0, 1)
133
- * }
134
- * ```
135
- */
136
- public abstract hasEdge(
137
- brep: BrepHandle,
138
- vertexIndexA: number,
139
- vertexIndexB: number
140
- ): PluginApiReturn<boolean>
141
-
142
- /**
143
- * List every edge connecting two vertices (by their brep vertex indices).
144
- * @param brep The brep to query
145
- * @param vertexIndexA First vertex index
146
- * @param vertexIndexB Second vertex index
147
- * @returns The edges as {@linkcode EdgeHandle}`[]`
148
- *
149
- * # Example
150
- * ```ts
151
- * const [wall] = await snaptrude.design.query.listWalls()
152
- * const brep = await snaptrude.design.query.geometry.getBrep(wall)
153
- * if (brep) {
154
- * // brep vertex indices (get one from core.geom.query.vertex.getIndex)
155
- * const edges = await snaptrude.core.geom.query.brep.listEdgesBetween(brep, 0, 1)
156
- * console.log("edges between vertices 0 and 1:", edges.length)
157
- * }
158
- * ```
159
- */
160
- public abstract listEdgesBetween(
161
- brep: BrepHandle,
162
- vertexIndexA: number,
163
- vertexIndexB: number
164
- ): PluginApiReturn<EdgeHandle[]>
165
-
166
- /**
167
- * Read the exact curve of a brep edge as plain values — a discriminated
168
- * union on `type`. Pure read: no geometry kernel is loaded. Points and
169
- * directions are {@linkcode Vec3Components}; lengths and radii are raw
170
- * Babylon units.
171
- *
172
- * | `type` | Fields |
173
- * |---|---|
174
- * | `"line"` | `startPoint`, `endPoint`, `length` |
175
- * | `"arc"` | `startPoint`, `endPoint`, `centre`, `axis`, `radius`, `length` |
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`.
182
- *
183
- * @param brep The brep the edge belongs to
184
- * @param edge The edge whose curve to read
185
- * @returns The curve data as a discriminated union on `type` (see table above)
186
- * @throws VALIDATION if the edge is not on `brep`
187
- * @throws PRECONDITION_FAILED if the edge is a RATIONAL (weighted) spline —
188
- * e.g. a NURBS-converted elliptical intersection edge. The wire form
189
- * carries no weights, so such an edge is refused rather than reported as a
190
- * different curve; sample it instead.
191
- *
192
- * @examplePrompt Read the radius of this curved edge
193
- * @examplePrompt Is this edge straight or an arc?
194
- * @examplePrompt Get the exact start and end points of this edge
195
- * @examplePrompt Measure the length of each edge of this mass
196
- * @examplePrompt Read the control points of this curved edge
197
- *
198
- * # Example
199
- * ```ts
200
- * const [mass] = await snaptrude.design.query.listMasses()
201
- * const brep = await snaptrude.design.query.geometry.getBrep(mass)
202
- * if (brep) {
203
- * const edges = await snaptrude.core.geom.query.brep.listEdges(brep)
204
- * for (const edge of edges) {
205
- * const curve = await snaptrude.core.geom.query.brep.getEdgeCurve(brep, edge)
206
- * if (curve.type === "arc") console.log("arc radius:", curve.radius)
207
- * }
208
- * }
209
- * ```
210
- */
211
- public abstract getEdgeCurve(
212
- brep: BrepHandle,
213
- edge: EdgeHandle
214
- ): PluginApiReturn<
215
- | { type: "line"; startPoint: Vec3Components; endPoint: Vec3Components; length: number }
216
- | {
217
- type: "arc"
218
- startPoint: Vec3Components
219
- endPoint: Vec3Components
220
- centre: Vec3Components
221
- axis: Vec3Components
222
- radius: number
223
- length: number
224
- }
225
- | {
226
- type: "circle"
227
- centre: Vec3Components
228
- axis: Vec3Components
229
- radius: number
230
- length: number
231
- }
232
- | {
233
- type: "spline"
234
- startPoint: Vec3Components
235
- endPoint: Vec3Components
236
- degree: number
237
- controlPoints: Vec3Components[]
238
- /** Expanded by multiplicity: `controlPoints.length + degree + 1` entries. */
239
- knots: number[]
240
- length: number
241
- }
242
- >
243
-
244
- /**
245
- * Get the position of a vertex within a brep.
246
- * @param brep The brep to query
247
- * @param vertex The vertex whose position to read
248
- * @returns The position as {@linkcode Vec3Components}
249
- *
250
- * # Example
251
- * ```ts
252
- * const [wall] = await snaptrude.design.query.listWalls()
253
- * const brep = await snaptrude.design.query.geometry.getBrep(wall)
254
- * if (brep) {
255
- * const [vertex] = await snaptrude.core.geom.query.brep.listVertices(brep)
256
- * const { x, y, z } = await snaptrude.core.geom.query.brep.getVertexPosition(brep, vertex)
257
- * }
258
- * ```
259
- */
260
- public abstract getVertexPosition(
261
- brep: BrepHandle,
262
- vertex: VertexHandle
263
- ): PluginApiReturn<Vec3Components>
264
-
265
- /**
266
- * List the positions of all vertices in a brep (ordered as {@linkcode PluginGeomQueryBrepApi.listVertices}).
267
- * @param brep The brep to query
268
- * @returns The positions as {@linkcode Vec3Components}`[]`
269
- *
270
- * @examplePrompt Get the coordinates of every corner of this shape
271
- * @examplePrompt Give me all the corner points of the selected mass as XYZ coordinates
272
- *
273
- * # Example
274
- * ```ts
275
- * const [mass] = await snaptrude.design.query.listMasses()
276
- * const brep = await snaptrude.design.query.geometry.getBrep(mass)
277
- * if (brep) {
278
- * const positions = await snaptrude.core.geom.query.brep.listVertexPositions(brep)
279
- * for (const p of positions) console.log(p.x, p.y, p.z)
280
- * }
281
- * ```
282
- */
283
- public abstract listVertexPositions(brep: BrepHandle): PluginApiReturn<Vec3Components[]>
284
-
285
- /**
286
- * Get the centroid of a brep: the mean of its vertex positions for planar
287
- * and cylinder-sided solids; for a solid with sphere, cone, torus or spline
288
- * geometry, its exact centre of mass (integrated over the surfaces; the
289
- * vertex mean again if the kernel cannot integrate it, e.g. an open brep).
290
- * @param brep The brep to query
291
- * @returns The centroid as {@linkcode Vec3Components}
292
- *
293
- * @examplePrompt Find the centre point of this shape
294
- * @examplePrompt What is the centroid of the selected object?
295
- *
296
- * # Example
297
- * ```ts
298
- * const [mass] = await snaptrude.design.query.listMasses()
299
- * const brep = await snaptrude.design.query.geometry.getBrep(mass)
300
- * if (brep) {
301
- * const centroid = await snaptrude.core.geom.query.brep.getCentroid(brep)
302
- * console.log(centroid.x, centroid.y, centroid.z)
303
- * }
304
- * ```
305
- */
306
- public abstract getCentroid(brep: BrepHandle): PluginApiReturn<Vec3Components>
307
-
308
- /**
309
- * Get the number of faces in a brep.
310
- * @param brep The brep to query
311
- * @returns The face count as a `number`
312
- *
313
- * # Example
314
- * ```ts
315
- * const [wall] = await snaptrude.design.query.listWalls()
316
- * const brep = await snaptrude.design.query.geometry.getBrep(wall)
317
- * if (brep) {
318
- * const faceCount = await snaptrude.core.geom.query.brep.getFaceCount(brep)
319
- * }
320
- * ```
321
- */
322
- public abstract getFaceCount(brep: BrepHandle): PluginApiReturn<number>
323
-
324
- /**
325
- * Get the number of edges in a brep.
326
- * @param brep The brep to query
327
- * @returns The edge count as a `number`
328
- *
329
- * # Example
330
- * ```ts
331
- * const [wall] = await snaptrude.design.query.listWalls()
332
- * const brep = await snaptrude.design.query.geometry.getBrep(wall)
333
- * if (brep) {
334
- * const edgeCount = await snaptrude.core.geom.query.brep.getEdgeCount(brep)
335
- * }
336
- * ```
337
- */
338
- public abstract getEdgeCount(brep: BrepHandle): PluginApiReturn<number>
339
-
340
- /**
341
- * Get the number of vertices in a brep.
342
- * @param brep The brep to query
343
- * @returns The vertex count as a `number`
344
- *
345
- * # Example
346
- * ```ts
347
- * const [mass] = await snaptrude.design.query.listMasses()
348
- * const brep = await snaptrude.design.query.geometry.getBrep(mass)
349
- * if (brep) {
350
- * const vertexCount = await snaptrude.core.geom.query.brep.getVertexCount(brep)
351
- * }
352
- * ```
353
- */
354
- public abstract getVertexCount(brep: BrepHandle): PluginApiReturn<number>
355
-
356
- /**
357
- * Get the number of half-edges in a brep.
358
- * @param brep The brep to query
359
- * @returns The half-edge count as a `number`
360
- *
361
- * # Example
362
- * ```ts
363
- * const [mass] = await snaptrude.design.query.listMasses()
364
- * const brep = await snaptrude.design.query.geometry.getBrep(mass)
365
- * if (brep) {
366
- * const halfEdgeCount = await snaptrude.core.geom.query.brep.getHalfEdgeCount(brep)
367
- * }
368
- * ```
369
- */
370
- public abstract getHalfEdgeCount(brep: BrepHandle): PluginApiReturn<number>
371
-
372
- /**
373
- * Get the axis-aligned bounding box of a brep.
374
- * @param brep The brep to query
375
- * @returns The bounding box as {@linkcode BBoxComponents}
376
- *
377
- * @examplePrompt What is the bounding box of this shape?
378
- * @examplePrompt How big is this object overall — give me its min and max extents
379
- *
380
- * # Example
381
- * ```ts
382
- * const [mass] = await snaptrude.design.query.listMasses()
383
- * const brep = await snaptrude.design.query.geometry.getBrep(mass)
384
- * if (brep) {
385
- * const { min, max } = await snaptrude.core.geom.query.brep.getBoundingBox(brep)
386
- * console.log("size:", max.x - min.x, max.y - min.y, max.z - min.z)
387
- * }
388
- * ```
389
- */
390
- public abstract getBoundingBox(brep: BrepHandle): PluginApiReturn<BBoxComponents>
391
-
392
- /**
393
- * Get the enclosed **volume** of a closed solid, integrated from its exact
394
- * surfaces. Curved faces are measured analytically, not from their
395
- * tessellation — a real sphere of radius 5 reports 523.6, whatever its
396
- * triangle count. That makes this the reliable way to confirm a solid is the
397
- * shape you intended (a torus should measure 2·π²·R·r²).
398
- *
399
- * Runs on the OpenCascade kernel (the first kernel call loads a wasm of tens
400
- * of MB — expect a pause of seconds).
401
- *
402
- * @param brep The solid to measure
403
- * @returns The enclosed volume in cubic internal length units
404
- * @throws OPERATION_FAILED if the kernel cannot compute the volume (the brep
405
- * is not a closed solid)
406
- *
407
- * @examplePrompt What is the volume of this mass?
408
- * @examplePrompt How much concrete is in this shape?
409
- * @examplePrompt Check the volume of the dome I just made
410
- *
411
- * # Example
412
- * ```ts
413
- * const [mass] = await snaptrude.design.query.listMasses()
414
- * const brep = await snaptrude.design.query.geometry.getBrep(mass)
415
- * if (brep) {
416
- * const volume = await snaptrude.core.geom.query.brep.getVolume(brep)
417
- * console.log("volume:", volume)
418
- * }
419
- * ```
420
- */
421
- public abstract getVolume(brep: BrepHandle): PluginApiReturn<number>
422
-
423
- /**
424
- * Test whether two breps are geometrically equal.
425
- * @param brepA First brep
426
- * @param brepB Second brep
427
- * @returns `true` if the breps are equal, otherwise `false`
428
- *
429
- * @examplePrompt Are these two shapes geometrically identical?
430
- * @examplePrompt Check whether these two objects have the same geometry
431
- *
432
- * # Example
433
- * ```ts
434
- * const [a, b] = await snaptrude.design.query.listMasses()
435
- * const brepA = await snaptrude.design.query.geometry.getBrep(a)
436
- * const brepB = await snaptrude.design.query.geometry.getBrep(b)
437
- * if (brepA && brepB) {
438
- * const same = await snaptrude.core.geom.query.brep.isEqual(brepA, brepB)
439
- * }
440
- * ```
441
- */
442
- public abstract isEqual(brepA: BrepHandle, brepB: BrepHandle): PluginApiReturn<boolean>
443
-
444
- /**
445
- * Measures the minimum distance between two solids, with the closest
446
- * point on each. Touching or overlapping solids report a distance of 0 with
447
- * contact points.
448
- *
449
- * @param brepA First solid
450
- * @param brepB Second solid
451
- * @returns `{ distance, pointA, pointB }` — the minimum distance and the
452
- * closest points on `brepA` and `brepB` as {@linkcode Vec3Components}
453
- * @throws OPERATION_FAILED if the kernel cannot compute the distance
454
- *
455
- * @examplePrompt What is the clearance between these two masses?
456
- * @examplePrompt How far apart are the tower and the neighbouring building?
457
- * @examplePrompt Find the closest points between these two solids
458
- *
459
- * # Example
460
- * ```ts
461
- * const [a, b] = await snaptrude.design.query.listMasses()
462
- * const brepA = await snaptrude.design.query.geometry.getBrep(a)
463
- * const brepB = await snaptrude.design.query.geometry.getBrep(b)
464
- * if (brepA && brepB) {
465
- * const { distance, pointA, pointB } = await snaptrude.core.geom.query.brep.getDistance(brepA, brepB)
466
- * console.log("clearance:", distance)
467
- * }
468
- * ```
469
- */
470
- public abstract getDistance(
471
- brepA: BrepHandle,
472
- brepB: BrepHandle
473
- ): PluginApiReturn<{ distance: number; pointA: Vec3Components; pointB: Vec3Components }>
474
- }
475
-
476
- const brepArg = z.object({ brep: BrepHandle })
477
- const brepEdgeArg = z.object({
478
- brep: BrepHandle,
479
- vertexIndexA: z.number(),
480
- vertexIndexB: z.number(),
481
- })
482
-
483
- /** Arguments for {@linkcode PluginGeomQueryBrepApi.listFaces}. `{ brep: BrepHandle }` */
484
- export const PluginGeomQueryBrepListFacesArgs = brepArg
485
- export type PluginGeomQueryBrepListFacesArgs = z.infer<typeof PluginGeomQueryBrepListFacesArgs>
486
-
487
- /** Arguments for {@linkcode PluginGeomQueryBrepApi.listEdges}. `{ brep: BrepHandle }` */
488
- export const PluginGeomQueryBrepListEdgesArgs = brepArg
489
- export type PluginGeomQueryBrepListEdgesArgs = z.infer<typeof PluginGeomQueryBrepListEdgesArgs>
490
-
491
- /** Arguments for {@linkcode PluginGeomQueryBrepApi.listVertices}. `{ brep: BrepHandle }` */
492
- export const PluginGeomQueryBrepListVerticesArgs = brepArg
493
- export type PluginGeomQueryBrepListVerticesArgs = z.infer<typeof PluginGeomQueryBrepListVerticesArgs>
494
-
495
- /** Arguments for {@linkcode PluginGeomQueryBrepApi.listHalfEdges}. `{ brep: BrepHandle }` */
496
- export const PluginGeomQueryBrepListHalfEdgesArgs = brepArg
497
- export type PluginGeomQueryBrepListHalfEdgesArgs = z.infer<
498
- typeof PluginGeomQueryBrepListHalfEdgesArgs
499
- >
500
-
501
- /**
502
- * Arguments for {@linkcode PluginGeomQueryBrepApi.getEdge}.
503
- *
504
- * | Property | Type | Description |
505
- * |---|---|---|
506
- * | `brep` | {@linkcode BrepHandle} | The brep to query |
507
- * | `vertexIndexA` | `number` | First vertex index |
508
- * | `vertexIndexB` | `number` | Second vertex index |
509
- */
510
- export const PluginGeomQueryBrepGetEdgeArgs = brepEdgeArg
511
- export type PluginGeomQueryBrepGetEdgeArgs = z.infer<typeof PluginGeomQueryBrepGetEdgeArgs>
512
-
513
- /** Arguments for {@linkcode PluginGeomQueryBrepApi.hasEdge}. `{ brep, vertexIndexA, vertexIndexB }` */
514
- export const PluginGeomQueryBrepHasEdgeArgs = brepEdgeArg
515
- export type PluginGeomQueryBrepHasEdgeArgs = z.infer<typeof PluginGeomQueryBrepHasEdgeArgs>
516
-
517
- /** Arguments for {@linkcode PluginGeomQueryBrepApi.listEdgesBetween}. `{ brep, vertexIndexA, vertexIndexB }` */
518
- export const PluginGeomQueryBrepListEdgesBetweenArgs = brepEdgeArg
519
- export type PluginGeomQueryBrepListEdgesBetweenArgs = z.infer<
520
- typeof PluginGeomQueryBrepListEdgesBetweenArgs
521
- >
522
-
523
- /**
524
- * Arguments for {@linkcode PluginGeomQueryBrepApi.getEdgeCurve}.
525
- *
526
- * | Property | Type | Description |
527
- * |---|---|---|
528
- * | `brep` | {@linkcode BrepHandle} | The brep the edge belongs to |
529
- * | `edge` | {@linkcode EdgeHandle} | The edge whose curve to read |
530
- */
531
- export const PluginGeomQueryBrepGetEdgeCurveArgs = z.object({
532
- brep: BrepHandle,
533
- edge: EdgeHandle,
534
- })
535
- export type PluginGeomQueryBrepGetEdgeCurveArgs = z.infer<
536
- typeof PluginGeomQueryBrepGetEdgeCurveArgs
537
- >
538
-
539
- /**
540
- * Arguments for {@linkcode PluginGeomQueryBrepApi.getVertexPosition}.
541
- *
542
- * | Property | Type | Description |
543
- * |---|---|---|
544
- * | `brep` | {@linkcode BrepHandle} | The brep to query |
545
- * | `vertex` | {@linkcode VertexHandle} | The vertex whose position to read |
546
- */
547
- export const PluginGeomQueryBrepGetVertexPositionArgs = z.object({
548
- brep: BrepHandle,
549
- vertex: VertexHandle,
550
- })
551
- export type PluginGeomQueryBrepGetVertexPositionArgs = z.infer<
552
- typeof PluginGeomQueryBrepGetVertexPositionArgs
553
- >
554
-
555
- /** Arguments for {@linkcode PluginGeomQueryBrepApi.listVertexPositions}. `{ brep: BrepHandle }` */
556
- export const PluginGeomQueryBrepListVertexPositionsArgs = brepArg
557
- export type PluginGeomQueryBrepListVertexPositionsArgs = z.infer<
558
- typeof PluginGeomQueryBrepListVertexPositionsArgs
559
- >
560
-
561
- /** Arguments for {@linkcode PluginGeomQueryBrepApi.getCentroid}. `{ brep: BrepHandle }` */
562
- export const PluginGeomQueryBrepGetCentroidArgs = brepArg
563
- export type PluginGeomQueryBrepGetCentroidArgs = z.infer<typeof PluginGeomQueryBrepGetCentroidArgs>
564
-
565
- /** Arguments for {@linkcode PluginGeomQueryBrepApi.getFaceCount}. `{ brep: BrepHandle }` */
566
- export const PluginGeomQueryBrepGetFaceCountArgs = brepArg
567
- export type PluginGeomQueryBrepGetFaceCountArgs = z.infer<typeof PluginGeomQueryBrepGetFaceCountArgs>
568
-
569
- /** Arguments for {@linkcode PluginGeomQueryBrepApi.getEdgeCount}. `{ brep: BrepHandle }` */
570
- export const PluginGeomQueryBrepGetEdgeCountArgs = brepArg
571
- export type PluginGeomQueryBrepGetEdgeCountArgs = z.infer<typeof PluginGeomQueryBrepGetEdgeCountArgs>
572
-
573
- /** Arguments for {@linkcode PluginGeomQueryBrepApi.getVertexCount}. `{ brep: BrepHandle }` */
574
- export const PluginGeomQueryBrepGetVertexCountArgs = brepArg
575
- export type PluginGeomQueryBrepGetVertexCountArgs = z.infer<
576
- typeof PluginGeomQueryBrepGetVertexCountArgs
577
- >
578
-
579
- /** Arguments for {@linkcode PluginGeomQueryBrepApi.getHalfEdgeCount}. `{ brep: BrepHandle }` */
580
- export const PluginGeomQueryBrepGetHalfEdgeCountArgs = brepArg
581
- export type PluginGeomQueryBrepGetHalfEdgeCountArgs = z.infer<
582
- typeof PluginGeomQueryBrepGetHalfEdgeCountArgs
583
- >
584
-
585
- /** Arguments for {@linkcode PluginGeomQueryBrepApi.getBoundingBox}. `{ brep: BrepHandle }` */
586
- export const PluginGeomQueryBrepGetBoundingBoxArgs = brepArg
587
- export type PluginGeomQueryBrepGetBoundingBoxArgs = z.infer<
588
- typeof PluginGeomQueryBrepGetBoundingBoxArgs
589
- >
590
-
591
- /** Arguments for {@linkcode PluginGeomQueryBrepApi.getVolume}. `{ brep: BrepHandle }` */
592
- export const PluginGeomQueryBrepGetVolumeArgs = brepArg
593
- export type PluginGeomQueryBrepGetVolumeArgs = z.infer<typeof PluginGeomQueryBrepGetVolumeArgs>
594
-
595
- /**
596
- * Arguments for {@linkcode PluginGeomQueryBrepApi.isEqual}.
597
- *
598
- * | Property | Type | Description |
599
- * |---|---|---|
600
- * | `brepA` | {@linkcode BrepHandle} | First brep |
601
- * | `brepB` | {@linkcode BrepHandle} | Second brep |
602
- */
603
- export const PluginGeomQueryBrepIsEqualArgs = z.object({
604
- brepA: BrepHandle,
605
- brepB: BrepHandle,
606
- })
607
- export type PluginGeomQueryBrepIsEqualArgs = z.infer<typeof PluginGeomQueryBrepIsEqualArgs>
608
-
609
- /**
610
- * Arguments for {@linkcode PluginGeomQueryBrepApi.getDistance}.
611
- *
612
- * | Property | Type | Description |
613
- * |---|---|---|
614
- * | `brepA` | {@linkcode BrepHandle} | First solid |
615
- * | `brepB` | {@linkcode BrepHandle} | Second solid |
616
- */
617
- export const PluginGeomQueryBrepGetDistanceArgs = z.object({
618
- brepA: BrepHandle,
619
- brepB: BrepHandle,
620
- })
621
- export type PluginGeomQueryBrepGetDistanceArgs = z.infer<typeof PluginGeomQueryBrepGetDistanceArgs>
1
+ import * as z from "zod"
2
+ import { PluginApiReturn } from "../../../../types"
3
+ import {
4
+ BrepHandle,
5
+ FaceHandle,
6
+ EdgeHandle,
7
+ VertexHandle,
8
+ HalfEdgeHandle,
9
+ Vec3Components,
10
+ BBoxComponents,
11
+ } from "../../../../handles"
12
+
13
+ /**
14
+ * BREP queries — read the topology and geometry of a boundary-representation mesh
15
+ * as plain values / child handles (all-handle model, §11). A {@linkcode BrepHandle}
16
+ * is a session-ephemeral resource handle obtained from `design.query.geometry.getBrep`;
17
+ * it goes stale on undo/redo/re-topologize.
18
+ *
19
+ * Enumerations mint fresh child topology handles ({@linkcode FaceHandle},
20
+ * {@linkcode EdgeHandle}, {@linkcode VertexHandle}, {@linkcode HalfEdgeHandle}); the
21
+ * registry dedupes by identity, so re-enumeration returns the same handles. Position
22
+ * reads return {@linkcode Vec3Components}. No query mutates its inputs.
23
+ *
24
+ * Accessed via `snaptrude.core.geom.query.brep`.
25
+ */
26
+ export abstract class PluginGeomQueryBrepApi {
27
+ constructor() {}
28
+
29
+ /**
30
+ * List the faces of a brep.
31
+ * @param brep The brep to query
32
+ * @returns The faces as {@linkcode FaceHandle}`[]`
33
+ *
34
+ * # Example
35
+ * ```ts
36
+ * const [wall] = await snaptrude.design.query.listWalls()
37
+ * const brep = await snaptrude.design.query.geometry.getBrep(wall)
38
+ * if (brep) {
39
+ * const faces = await snaptrude.core.geom.query.brep.listFaces(brep)
40
+ * }
41
+ * ```
42
+ */
43
+ public abstract listFaces(brep: BrepHandle): PluginApiReturn<FaceHandle[]>
44
+
45
+ /**
46
+ * List the edges of a brep.
47
+ * @param brep The brep to query
48
+ * @returns The edges as {@linkcode EdgeHandle}`[]`
49
+ *
50
+ * # Example
51
+ * ```ts
52
+ * const [wall] = await snaptrude.design.query.listWalls()
53
+ * const brep = await snaptrude.design.query.geometry.getBrep(wall)
54
+ * if (brep) {
55
+ * const edges = await snaptrude.core.geom.query.brep.listEdges(brep)
56
+ * }
57
+ * ```
58
+ */
59
+ public abstract listEdges(brep: BrepHandle): PluginApiReturn<EdgeHandle[]>
60
+
61
+ /**
62
+ * List the vertices of a brep.
63
+ * @param brep The brep to query
64
+ * @returns The vertices as {@linkcode VertexHandle}`[]`
65
+ *
66
+ * # Example
67
+ * ```ts
68
+ * const [mass] = await snaptrude.design.query.listMasses()
69
+ * const brep = await snaptrude.design.query.geometry.getBrep(mass)
70
+ * if (brep) {
71
+ * const vertices = await snaptrude.core.geom.query.brep.listVertices(brep)
72
+ * }
73
+ * ```
74
+ */
75
+ public abstract listVertices(brep: BrepHandle): PluginApiReturn<VertexHandle[]>
76
+
77
+ /**
78
+ * List the half-edges of a brep.
79
+ * @param brep The brep to query
80
+ * @returns The half-edges as {@linkcode HalfEdgeHandle}`[]`
81
+ *
82
+ * # Example
83
+ * ```ts
84
+ * const [wall] = await snaptrude.design.query.listWalls()
85
+ * const brep = await snaptrude.design.query.geometry.getBrep(wall)
86
+ * if (brep) {
87
+ * const halfEdges = await snaptrude.core.geom.query.brep.listHalfEdges(brep)
88
+ * }
89
+ * ```
90
+ */
91
+ public abstract listHalfEdges(brep: BrepHandle): PluginApiReturn<HalfEdgeHandle[]>
92
+
93
+ /**
94
+ * Get the edge connecting two vertices (by their brep vertex indices).
95
+ * @param brep The brep to query
96
+ * @param vertexIndexA First vertex index
97
+ * @param vertexIndexB Second vertex index
98
+ * @returns The edge as an {@linkcode EdgeHandle}, or `null` if no such edge exists
99
+ *
100
+ * # Example
101
+ * ```ts
102
+ * const [wall] = await snaptrude.design.query.listWalls()
103
+ * const brep = await snaptrude.design.query.geometry.getBrep(wall)
104
+ * if (brep) {
105
+ * const [va, vb] = await snaptrude.core.geom.query.brep.listVertices(brep)
106
+ * const ia = await snaptrude.core.geom.query.vertex.getIndex(va)
107
+ * const ib = await snaptrude.core.geom.query.vertex.getIndex(vb)
108
+ * const edge = await snaptrude.core.geom.query.brep.getEdge(brep, ia, ib)
109
+ * if (edge) console.log("those two vertices are connected")
110
+ * }
111
+ * ```
112
+ */
113
+ public abstract getEdge(
114
+ brep: BrepHandle,
115
+ vertexIndexA: number,
116
+ vertexIndexB: number
117
+ ): PluginApiReturn<EdgeHandle | null>
118
+
119
+ /**
120
+ * Test whether an edge connects two vertices (by their brep vertex indices).
121
+ * @param brep The brep to query
122
+ * @param vertexIndexA First vertex index
123
+ * @param vertexIndexB Second vertex index
124
+ * @returns `true` if such an edge exists, otherwise `false`
125
+ *
126
+ * # Example
127
+ * ```ts
128
+ * const [wall] = await snaptrude.design.query.listWalls()
129
+ * const brep = await snaptrude.design.query.geometry.getBrep(wall)
130
+ * if (brep) {
131
+ * // brep vertex indices (get one from core.geom.query.vertex.getIndex)
132
+ * const connected = await snaptrude.core.geom.query.brep.hasEdge(brep, 0, 1)
133
+ * }
134
+ * ```
135
+ */
136
+ public abstract hasEdge(
137
+ brep: BrepHandle,
138
+ vertexIndexA: number,
139
+ vertexIndexB: number
140
+ ): PluginApiReturn<boolean>
141
+
142
+ /**
143
+ * List every edge connecting two vertices (by their brep vertex indices).
144
+ * @param brep The brep to query
145
+ * @param vertexIndexA First vertex index
146
+ * @param vertexIndexB Second vertex index
147
+ * @returns The edges as {@linkcode EdgeHandle}`[]`
148
+ *
149
+ * # Example
150
+ * ```ts
151
+ * const [wall] = await snaptrude.design.query.listWalls()
152
+ * const brep = await snaptrude.design.query.geometry.getBrep(wall)
153
+ * if (brep) {
154
+ * // brep vertex indices (get one from core.geom.query.vertex.getIndex)
155
+ * const edges = await snaptrude.core.geom.query.brep.listEdgesBetween(brep, 0, 1)
156
+ * console.log("edges between vertices 0 and 1:", edges.length)
157
+ * }
158
+ * ```
159
+ */
160
+ public abstract listEdgesBetween(
161
+ brep: BrepHandle,
162
+ vertexIndexA: number,
163
+ vertexIndexB: number
164
+ ): PluginApiReturn<EdgeHandle[]>
165
+
166
+ /**
167
+ * Read the exact curve of a brep edge as plain values — a discriminated
168
+ * union on `type`. Pure read: no geometry kernel is loaded. Points and
169
+ * directions are {@linkcode Vec3Components}; lengths and radii are raw
170
+ * Babylon units.
171
+ *
172
+ * | `type` | Fields |
173
+ * |---|---|
174
+ * | `"line"` | `startPoint`, `endPoint`, `length` |
175
+ * | `"arc"` | `startPoint`, `endPoint`, `centre`, `axis`, `radius`, `length` |
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`.
182
+ *
183
+ * @param brep The brep the edge belongs to
184
+ * @param edge The edge whose curve to read
185
+ * @returns The curve data as a discriminated union on `type` (see table above)
186
+ * @throws VALIDATION if the edge is not on `brep`
187
+ * @throws PRECONDITION_FAILED if the edge is a RATIONAL (weighted) spline —
188
+ * e.g. a NURBS-converted elliptical intersection edge. The wire form
189
+ * carries no weights, so such an edge is refused rather than reported as a
190
+ * different curve; sample it instead.
191
+ *
192
+ * @examplePrompt Read the radius of this curved edge
193
+ * @examplePrompt Is this edge straight or an arc?
194
+ * @examplePrompt Get the exact start and end points of this edge
195
+ * @examplePrompt Measure the length of each edge of this mass
196
+ * @examplePrompt Read the control points of this curved edge
197
+ *
198
+ * # Example
199
+ * ```ts
200
+ * const [mass] = await snaptrude.design.query.listMasses()
201
+ * const brep = await snaptrude.design.query.geometry.getBrep(mass)
202
+ * if (brep) {
203
+ * const edges = await snaptrude.core.geom.query.brep.listEdges(brep)
204
+ * for (const edge of edges) {
205
+ * const curve = await snaptrude.core.geom.query.brep.getEdgeCurve(brep, edge)
206
+ * if (curve.type === "arc") console.log("arc radius:", curve.radius)
207
+ * }
208
+ * }
209
+ * ```
210
+ */
211
+ public abstract getEdgeCurve(
212
+ brep: BrepHandle,
213
+ edge: EdgeHandle
214
+ ): PluginApiReturn<
215
+ | { type: "line"; startPoint: Vec3Components; endPoint: Vec3Components; length: number }
216
+ | {
217
+ type: "arc"
218
+ startPoint: Vec3Components
219
+ endPoint: Vec3Components
220
+ centre: Vec3Components
221
+ axis: Vec3Components
222
+ radius: number
223
+ length: number
224
+ }
225
+ | {
226
+ type: "circle"
227
+ centre: Vec3Components
228
+ axis: Vec3Components
229
+ radius: number
230
+ length: number
231
+ }
232
+ | {
233
+ type: "spline"
234
+ startPoint: Vec3Components
235
+ endPoint: Vec3Components
236
+ degree: number
237
+ controlPoints: Vec3Components[]
238
+ /** Expanded by multiplicity: `controlPoints.length + degree + 1` entries. */
239
+ knots: number[]
240
+ length: number
241
+ }
242
+ >
243
+
244
+ /**
245
+ * Get the position of a vertex within a brep.
246
+ * @param brep The brep to query
247
+ * @param vertex The vertex whose position to read
248
+ * @returns The position as {@linkcode Vec3Components}
249
+ *
250
+ * # Example
251
+ * ```ts
252
+ * const [wall] = await snaptrude.design.query.listWalls()
253
+ * const brep = await snaptrude.design.query.geometry.getBrep(wall)
254
+ * if (brep) {
255
+ * const [vertex] = await snaptrude.core.geom.query.brep.listVertices(brep)
256
+ * const { x, y, z } = await snaptrude.core.geom.query.brep.getVertexPosition(brep, vertex)
257
+ * }
258
+ * ```
259
+ */
260
+ public abstract getVertexPosition(
261
+ brep: BrepHandle,
262
+ vertex: VertexHandle
263
+ ): PluginApiReturn<Vec3Components>
264
+
265
+ /**
266
+ * List the positions of all vertices in a brep (ordered as {@linkcode PluginGeomQueryBrepApi.listVertices}).
267
+ * @param brep The brep to query
268
+ * @returns The positions as {@linkcode Vec3Components}`[]`
269
+ *
270
+ * @examplePrompt Get the coordinates of every corner of this shape
271
+ * @examplePrompt Give me all the corner points of the selected mass as XYZ coordinates
272
+ *
273
+ * # Example
274
+ * ```ts
275
+ * const [mass] = await snaptrude.design.query.listMasses()
276
+ * const brep = await snaptrude.design.query.geometry.getBrep(mass)
277
+ * if (brep) {
278
+ * const positions = await snaptrude.core.geom.query.brep.listVertexPositions(brep)
279
+ * for (const p of positions) console.log(p.x, p.y, p.z)
280
+ * }
281
+ * ```
282
+ */
283
+ public abstract listVertexPositions(brep: BrepHandle): PluginApiReturn<Vec3Components[]>
284
+
285
+ /**
286
+ * Get the centroid of a brep: the mean of its vertex positions for planar
287
+ * and cylinder-sided solids; for a solid with sphere, cone, torus or spline
288
+ * geometry, its exact centre of mass (integrated over the surfaces; the
289
+ * vertex mean again if the kernel cannot integrate it, e.g. an open brep).
290
+ * @param brep The brep to query
291
+ * @returns The centroid as {@linkcode Vec3Components}
292
+ *
293
+ * @examplePrompt Find the centre point of this shape
294
+ * @examplePrompt What is the centroid of the selected object?
295
+ *
296
+ * # Example
297
+ * ```ts
298
+ * const [mass] = await snaptrude.design.query.listMasses()
299
+ * const brep = await snaptrude.design.query.geometry.getBrep(mass)
300
+ * if (brep) {
301
+ * const centroid = await snaptrude.core.geom.query.brep.getCentroid(brep)
302
+ * console.log(centroid.x, centroid.y, centroid.z)
303
+ * }
304
+ * ```
305
+ */
306
+ public abstract getCentroid(brep: BrepHandle): PluginApiReturn<Vec3Components>
307
+
308
+ /**
309
+ * Get the number of faces in a brep.
310
+ * @param brep The brep to query
311
+ * @returns The face count as a `number`
312
+ *
313
+ * # Example
314
+ * ```ts
315
+ * const [wall] = await snaptrude.design.query.listWalls()
316
+ * const brep = await snaptrude.design.query.geometry.getBrep(wall)
317
+ * if (brep) {
318
+ * const faceCount = await snaptrude.core.geom.query.brep.getFaceCount(brep)
319
+ * }
320
+ * ```
321
+ */
322
+ public abstract getFaceCount(brep: BrepHandle): PluginApiReturn<number>
323
+
324
+ /**
325
+ * Get the number of edges in a brep.
326
+ * @param brep The brep to query
327
+ * @returns The edge count as a `number`
328
+ *
329
+ * # Example
330
+ * ```ts
331
+ * const [wall] = await snaptrude.design.query.listWalls()
332
+ * const brep = await snaptrude.design.query.geometry.getBrep(wall)
333
+ * if (brep) {
334
+ * const edgeCount = await snaptrude.core.geom.query.brep.getEdgeCount(brep)
335
+ * }
336
+ * ```
337
+ */
338
+ public abstract getEdgeCount(brep: BrepHandle): PluginApiReturn<number>
339
+
340
+ /**
341
+ * Get the number of vertices in a brep.
342
+ * @param brep The brep to query
343
+ * @returns The vertex count as a `number`
344
+ *
345
+ * # Example
346
+ * ```ts
347
+ * const [mass] = await snaptrude.design.query.listMasses()
348
+ * const brep = await snaptrude.design.query.geometry.getBrep(mass)
349
+ * if (brep) {
350
+ * const vertexCount = await snaptrude.core.geom.query.brep.getVertexCount(brep)
351
+ * }
352
+ * ```
353
+ */
354
+ public abstract getVertexCount(brep: BrepHandle): PluginApiReturn<number>
355
+
356
+ /**
357
+ * Get the number of half-edges in a brep.
358
+ * @param brep The brep to query
359
+ * @returns The half-edge count as a `number`
360
+ *
361
+ * # Example
362
+ * ```ts
363
+ * const [mass] = await snaptrude.design.query.listMasses()
364
+ * const brep = await snaptrude.design.query.geometry.getBrep(mass)
365
+ * if (brep) {
366
+ * const halfEdgeCount = await snaptrude.core.geom.query.brep.getHalfEdgeCount(brep)
367
+ * }
368
+ * ```
369
+ */
370
+ public abstract getHalfEdgeCount(brep: BrepHandle): PluginApiReturn<number>
371
+
372
+ /**
373
+ * Get the axis-aligned bounding box of a brep.
374
+ * @param brep The brep to query
375
+ * @returns The bounding box as {@linkcode BBoxComponents}
376
+ *
377
+ * @examplePrompt What is the bounding box of this shape?
378
+ * @examplePrompt How big is this object overall — give me its min and max extents
379
+ *
380
+ * # Example
381
+ * ```ts
382
+ * const [mass] = await snaptrude.design.query.listMasses()
383
+ * const brep = await snaptrude.design.query.geometry.getBrep(mass)
384
+ * if (brep) {
385
+ * const { min, max } = await snaptrude.core.geom.query.brep.getBoundingBox(brep)
386
+ * console.log("size:", max.x - min.x, max.y - min.y, max.z - min.z)
387
+ * }
388
+ * ```
389
+ */
390
+ public abstract getBoundingBox(brep: BrepHandle): PluginApiReturn<BBoxComponents>
391
+
392
+ /**
393
+ * Get the enclosed **volume** of a closed solid, integrated from its exact
394
+ * surfaces. Curved faces are measured analytically, not from their
395
+ * tessellation — a real sphere of radius 5 reports 523.6, whatever its
396
+ * triangle count. That makes this the reliable way to confirm a solid is the
397
+ * shape you intended (a torus should measure 2·π²·R·r²).
398
+ *
399
+ * Runs on the OpenCascade kernel (the first kernel call loads a wasm of tens
400
+ * of MB — expect a pause of seconds).
401
+ *
402
+ * @param brep The solid to measure
403
+ * @returns The enclosed volume in cubic internal length units
404
+ * @throws OPERATION_FAILED if the kernel cannot compute the volume (the brep
405
+ * is not a closed solid)
406
+ *
407
+ * @examplePrompt What is the volume of this mass?
408
+ * @examplePrompt How much concrete is in this shape?
409
+ * @examplePrompt Check the volume of the dome I just made
410
+ *
411
+ * # Example
412
+ * ```ts
413
+ * const [mass] = await snaptrude.design.query.listMasses()
414
+ * const brep = await snaptrude.design.query.geometry.getBrep(mass)
415
+ * if (brep) {
416
+ * const volume = await snaptrude.core.geom.query.brep.getVolume(brep)
417
+ * console.log("volume:", volume)
418
+ * }
419
+ * ```
420
+ */
421
+ public abstract getVolume(brep: BrepHandle): PluginApiReturn<number>
422
+
423
+ /**
424
+ * Test whether two breps are geometrically equal.
425
+ * @param brepA First brep
426
+ * @param brepB Second brep
427
+ * @returns `true` if the breps are equal, otherwise `false`
428
+ *
429
+ * @examplePrompt Are these two shapes geometrically identical?
430
+ * @examplePrompt Check whether these two objects have the same geometry
431
+ *
432
+ * # Example
433
+ * ```ts
434
+ * const [a, b] = await snaptrude.design.query.listMasses()
435
+ * const brepA = await snaptrude.design.query.geometry.getBrep(a)
436
+ * const brepB = await snaptrude.design.query.geometry.getBrep(b)
437
+ * if (brepA && brepB) {
438
+ * const same = await snaptrude.core.geom.query.brep.isEqual(brepA, brepB)
439
+ * }
440
+ * ```
441
+ */
442
+ public abstract isEqual(brepA: BrepHandle, brepB: BrepHandle): PluginApiReturn<boolean>
443
+
444
+ /**
445
+ * Measures the minimum distance between two solids, with the closest
446
+ * point on each. Touching or overlapping solids report a distance of 0 with
447
+ * contact points.
448
+ *
449
+ * @param brepA First solid
450
+ * @param brepB Second solid
451
+ * @returns `{ distance, pointA, pointB }` — the minimum distance and the
452
+ * closest points on `brepA` and `brepB` as {@linkcode Vec3Components}
453
+ * @throws OPERATION_FAILED if the kernel cannot compute the distance
454
+ *
455
+ * @examplePrompt What is the clearance between these two masses?
456
+ * @examplePrompt How far apart are the tower and the neighbouring building?
457
+ * @examplePrompt Find the closest points between these two solids
458
+ *
459
+ * # Example
460
+ * ```ts
461
+ * const [a, b] = await snaptrude.design.query.listMasses()
462
+ * const brepA = await snaptrude.design.query.geometry.getBrep(a)
463
+ * const brepB = await snaptrude.design.query.geometry.getBrep(b)
464
+ * if (brepA && brepB) {
465
+ * const { distance, pointA, pointB } = await snaptrude.core.geom.query.brep.getDistance(brepA, brepB)
466
+ * console.log("clearance:", distance)
467
+ * }
468
+ * ```
469
+ */
470
+ public abstract getDistance(
471
+ brepA: BrepHandle,
472
+ brepB: BrepHandle
473
+ ): PluginApiReturn<{ distance: number; pointA: Vec3Components; pointB: Vec3Components }>
474
+ }
475
+
476
+ const brepArg = z.object({ brep: BrepHandle })
477
+ const brepEdgeArg = z.object({
478
+ brep: BrepHandle,
479
+ vertexIndexA: z.number(),
480
+ vertexIndexB: z.number(),
481
+ })
482
+
483
+ /** Arguments for {@linkcode PluginGeomQueryBrepApi.listFaces}. `{ brep: BrepHandle }` */
484
+ export const PluginGeomQueryBrepListFacesArgs = brepArg
485
+ export type PluginGeomQueryBrepListFacesArgs = z.infer<typeof PluginGeomQueryBrepListFacesArgs>
486
+
487
+ /** Arguments for {@linkcode PluginGeomQueryBrepApi.listEdges}. `{ brep: BrepHandle }` */
488
+ export const PluginGeomQueryBrepListEdgesArgs = brepArg
489
+ export type PluginGeomQueryBrepListEdgesArgs = z.infer<typeof PluginGeomQueryBrepListEdgesArgs>
490
+
491
+ /** Arguments for {@linkcode PluginGeomQueryBrepApi.listVertices}. `{ brep: BrepHandle }` */
492
+ export const PluginGeomQueryBrepListVerticesArgs = brepArg
493
+ export type PluginGeomQueryBrepListVerticesArgs = z.infer<typeof PluginGeomQueryBrepListVerticesArgs>
494
+
495
+ /** Arguments for {@linkcode PluginGeomQueryBrepApi.listHalfEdges}. `{ brep: BrepHandle }` */
496
+ export const PluginGeomQueryBrepListHalfEdgesArgs = brepArg
497
+ export type PluginGeomQueryBrepListHalfEdgesArgs = z.infer<
498
+ typeof PluginGeomQueryBrepListHalfEdgesArgs
499
+ >
500
+
501
+ /**
502
+ * Arguments for {@linkcode PluginGeomQueryBrepApi.getEdge}.
503
+ *
504
+ * | Property | Type | Description |
505
+ * |---|---|---|
506
+ * | `brep` | {@linkcode BrepHandle} | The brep to query |
507
+ * | `vertexIndexA` | `number` | First vertex index |
508
+ * | `vertexIndexB` | `number` | Second vertex index |
509
+ */
510
+ export const PluginGeomQueryBrepGetEdgeArgs = brepEdgeArg
511
+ export type PluginGeomQueryBrepGetEdgeArgs = z.infer<typeof PluginGeomQueryBrepGetEdgeArgs>
512
+
513
+ /** Arguments for {@linkcode PluginGeomQueryBrepApi.hasEdge}. `{ brep, vertexIndexA, vertexIndexB }` */
514
+ export const PluginGeomQueryBrepHasEdgeArgs = brepEdgeArg
515
+ export type PluginGeomQueryBrepHasEdgeArgs = z.infer<typeof PluginGeomQueryBrepHasEdgeArgs>
516
+
517
+ /** Arguments for {@linkcode PluginGeomQueryBrepApi.listEdgesBetween}. `{ brep, vertexIndexA, vertexIndexB }` */
518
+ export const PluginGeomQueryBrepListEdgesBetweenArgs = brepEdgeArg
519
+ export type PluginGeomQueryBrepListEdgesBetweenArgs = z.infer<
520
+ typeof PluginGeomQueryBrepListEdgesBetweenArgs
521
+ >
522
+
523
+ /**
524
+ * Arguments for {@linkcode PluginGeomQueryBrepApi.getEdgeCurve}.
525
+ *
526
+ * | Property | Type | Description |
527
+ * |---|---|---|
528
+ * | `brep` | {@linkcode BrepHandle} | The brep the edge belongs to |
529
+ * | `edge` | {@linkcode EdgeHandle} | The edge whose curve to read |
530
+ */
531
+ export const PluginGeomQueryBrepGetEdgeCurveArgs = z.object({
532
+ brep: BrepHandle,
533
+ edge: EdgeHandle,
534
+ })
535
+ export type PluginGeomQueryBrepGetEdgeCurveArgs = z.infer<
536
+ typeof PluginGeomQueryBrepGetEdgeCurveArgs
537
+ >
538
+
539
+ /**
540
+ * Arguments for {@linkcode PluginGeomQueryBrepApi.getVertexPosition}.
541
+ *
542
+ * | Property | Type | Description |
543
+ * |---|---|---|
544
+ * | `brep` | {@linkcode BrepHandle} | The brep to query |
545
+ * | `vertex` | {@linkcode VertexHandle} | The vertex whose position to read |
546
+ */
547
+ export const PluginGeomQueryBrepGetVertexPositionArgs = z.object({
548
+ brep: BrepHandle,
549
+ vertex: VertexHandle,
550
+ })
551
+ export type PluginGeomQueryBrepGetVertexPositionArgs = z.infer<
552
+ typeof PluginGeomQueryBrepGetVertexPositionArgs
553
+ >
554
+
555
+ /** Arguments for {@linkcode PluginGeomQueryBrepApi.listVertexPositions}. `{ brep: BrepHandle }` */
556
+ export const PluginGeomQueryBrepListVertexPositionsArgs = brepArg
557
+ export type PluginGeomQueryBrepListVertexPositionsArgs = z.infer<
558
+ typeof PluginGeomQueryBrepListVertexPositionsArgs
559
+ >
560
+
561
+ /** Arguments for {@linkcode PluginGeomQueryBrepApi.getCentroid}. `{ brep: BrepHandle }` */
562
+ export const PluginGeomQueryBrepGetCentroidArgs = brepArg
563
+ export type PluginGeomQueryBrepGetCentroidArgs = z.infer<typeof PluginGeomQueryBrepGetCentroidArgs>
564
+
565
+ /** Arguments for {@linkcode PluginGeomQueryBrepApi.getFaceCount}. `{ brep: BrepHandle }` */
566
+ export const PluginGeomQueryBrepGetFaceCountArgs = brepArg
567
+ export type PluginGeomQueryBrepGetFaceCountArgs = z.infer<typeof PluginGeomQueryBrepGetFaceCountArgs>
568
+
569
+ /** Arguments for {@linkcode PluginGeomQueryBrepApi.getEdgeCount}. `{ brep: BrepHandle }` */
570
+ export const PluginGeomQueryBrepGetEdgeCountArgs = brepArg
571
+ export type PluginGeomQueryBrepGetEdgeCountArgs = z.infer<typeof PluginGeomQueryBrepGetEdgeCountArgs>
572
+
573
+ /** Arguments for {@linkcode PluginGeomQueryBrepApi.getVertexCount}. `{ brep: BrepHandle }` */
574
+ export const PluginGeomQueryBrepGetVertexCountArgs = brepArg
575
+ export type PluginGeomQueryBrepGetVertexCountArgs = z.infer<
576
+ typeof PluginGeomQueryBrepGetVertexCountArgs
577
+ >
578
+
579
+ /** Arguments for {@linkcode PluginGeomQueryBrepApi.getHalfEdgeCount}. `{ brep: BrepHandle }` */
580
+ export const PluginGeomQueryBrepGetHalfEdgeCountArgs = brepArg
581
+ export type PluginGeomQueryBrepGetHalfEdgeCountArgs = z.infer<
582
+ typeof PluginGeomQueryBrepGetHalfEdgeCountArgs
583
+ >
584
+
585
+ /** Arguments for {@linkcode PluginGeomQueryBrepApi.getBoundingBox}. `{ brep: BrepHandle }` */
586
+ export const PluginGeomQueryBrepGetBoundingBoxArgs = brepArg
587
+ export type PluginGeomQueryBrepGetBoundingBoxArgs = z.infer<
588
+ typeof PluginGeomQueryBrepGetBoundingBoxArgs
589
+ >
590
+
591
+ /** Arguments for {@linkcode PluginGeomQueryBrepApi.getVolume}. `{ brep: BrepHandle }` */
592
+ export const PluginGeomQueryBrepGetVolumeArgs = brepArg
593
+ export type PluginGeomQueryBrepGetVolumeArgs = z.infer<typeof PluginGeomQueryBrepGetVolumeArgs>
594
+
595
+ /**
596
+ * Arguments for {@linkcode PluginGeomQueryBrepApi.isEqual}.
597
+ *
598
+ * | Property | Type | Description |
599
+ * |---|---|---|
600
+ * | `brepA` | {@linkcode BrepHandle} | First brep |
601
+ * | `brepB` | {@linkcode BrepHandle} | Second brep |
602
+ */
603
+ export const PluginGeomQueryBrepIsEqualArgs = z.object({
604
+ brepA: BrepHandle,
605
+ brepB: BrepHandle,
606
+ })
607
+ export type PluginGeomQueryBrepIsEqualArgs = z.infer<typeof PluginGeomQueryBrepIsEqualArgs>
608
+
609
+ /**
610
+ * Arguments for {@linkcode PluginGeomQueryBrepApi.getDistance}.
611
+ *
612
+ * | Property | Type | Description |
613
+ * |---|---|---|
614
+ * | `brepA` | {@linkcode BrepHandle} | First solid |
615
+ * | `brepB` | {@linkcode BrepHandle} | Second solid |
616
+ */
617
+ export const PluginGeomQueryBrepGetDistanceArgs = z.object({
618
+ brepA: BrepHandle,
619
+ brepB: BrepHandle,
620
+ })
621
+ export type PluginGeomQueryBrepGetDistanceArgs = z.infer<typeof PluginGeomQueryBrepGetDistanceArgs>