@snaptrude/plugin-core 0.3.0 → 0.5.0

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 (266) hide show
  1. package/AGENTS.md +130 -48
  2. package/CHANGELOG.md +111 -0
  3. package/api-manifest.full.json +3999 -0
  4. package/api-manifest.json +3845 -0
  5. package/dist/api/core/buildings.d.ts +427 -0
  6. package/dist/api/core/buildings.d.ts.map +1 -0
  7. package/dist/api/core/comment/index.d.ts +230 -0
  8. package/dist/api/core/comment/index.d.ts.map +1 -0
  9. package/dist/api/core/geom/create/index.d.ts +247 -0
  10. package/dist/api/core/geom/create/index.d.ts.map +1 -0
  11. package/dist/api/core/geom/delete/index.d.ts +72 -0
  12. package/dist/api/core/geom/delete/index.d.ts.map +1 -0
  13. package/dist/api/core/geom/index.d.ts +24 -23
  14. package/dist/api/core/geom/index.d.ts.map +1 -1
  15. package/dist/api/core/geom/query/arc.d.ts +169 -0
  16. package/dist/api/core/geom/query/arc.d.ts.map +1 -0
  17. package/dist/api/core/geom/query/brep.d.ts +402 -0
  18. package/dist/api/core/geom/query/brep.d.ts.map +1 -0
  19. package/dist/api/core/geom/query/circle.d.ts +378 -0
  20. package/dist/api/core/geom/query/circle.d.ts.map +1 -0
  21. package/dist/api/core/geom/query/contour.d.ts +450 -0
  22. package/dist/api/core/geom/query/contour.d.ts.map +1 -0
  23. package/dist/api/core/geom/query/curve.d.ts +918 -0
  24. package/dist/api/core/geom/query/curve.d.ts.map +1 -0
  25. package/dist/api/core/geom/query/edge.d.ts +128 -0
  26. package/dist/api/core/geom/query/edge.d.ts.map +1 -0
  27. package/dist/api/core/geom/query/face.d.ts +363 -0
  28. package/dist/api/core/geom/query/face.d.ts.map +1 -0
  29. package/dist/api/core/geom/query/halfedge.d.ts +206 -0
  30. package/dist/api/core/geom/query/halfedge.d.ts.map +1 -0
  31. package/dist/api/core/geom/query/index.d.ts +61 -0
  32. package/dist/api/core/geom/query/index.d.ts.map +1 -0
  33. package/dist/api/core/geom/query/profile.d.ts +410 -0
  34. package/dist/api/core/geom/query/profile.d.ts.map +1 -0
  35. package/dist/api/core/geom/query/vertex.d.ts +187 -0
  36. package/dist/api/core/geom/query/vertex.d.ts.map +1 -0
  37. package/dist/api/core/geom/update/contour.d.ts +272 -0
  38. package/dist/api/core/geom/update/contour.d.ts.map +1 -0
  39. package/dist/api/core/geom/update/curve.d.ts +180 -0
  40. package/dist/api/core/geom/update/curve.d.ts.map +1 -0
  41. package/dist/api/core/geom/update/index.d.ts +27 -0
  42. package/dist/api/core/geom/update/index.d.ts.map +1 -0
  43. package/dist/api/core/geom/update/profile.d.ts +329 -0
  44. package/dist/api/core/geom/update/profile.d.ts.map +1 -0
  45. package/dist/api/core/groups.d.ts +485 -0
  46. package/dist/api/core/groups.d.ts.map +1 -0
  47. package/dist/api/core/history/index.d.ts +78 -0
  48. package/dist/api/core/history/index.d.ts.map +1 -0
  49. package/dist/api/core/index.d.ts +46 -1
  50. package/dist/api/core/index.d.ts.map +1 -1
  51. package/dist/api/core/layers.d.ts +402 -0
  52. package/dist/api/core/layers.d.ts.map +1 -0
  53. package/dist/api/core/math/quat.d.ts +111 -128
  54. package/dist/api/core/math/quat.d.ts.map +1 -1
  55. package/dist/api/core/math/vec3.d.ts +120 -102
  56. package/dist/api/core/math/vec3.d.ts.map +1 -1
  57. package/dist/api/core/project/index.d.ts +399 -0
  58. package/dist/api/core/project/index.d.ts.map +1 -0
  59. package/dist/api/core/tags.d.ts +755 -0
  60. package/dist/api/core/tags.d.ts.map +1 -0
  61. package/dist/api/core/units/index.d.ts +175 -0
  62. package/dist/api/core/units/index.d.ts.map +1 -0
  63. package/dist/api/core/zoom/index.d.ts +45 -0
  64. package/dist/api/core/zoom/index.d.ts.map +1 -0
  65. package/dist/api/design/boolean/index.d.ts +168 -0
  66. package/dist/api/design/boolean/index.d.ts.map +1 -0
  67. package/dist/api/design/create/index.d.ts +828 -0
  68. package/dist/api/design/create/index.d.ts.map +1 -0
  69. package/dist/api/design/delete/index.d.ts +63 -0
  70. package/dist/api/design/delete/index.d.ts.map +1 -0
  71. package/dist/api/design/doors/index.d.ts +268 -0
  72. package/dist/api/design/doors/index.d.ts.map +1 -0
  73. package/dist/api/design/edit/index.d.ts +49 -0
  74. package/dist/api/design/edit/index.d.ts.map +1 -0
  75. package/dist/api/design/erase/index.d.ts +160 -0
  76. package/dist/api/design/erase/index.d.ts.map +1 -0
  77. package/dist/api/design/furniture/index.d.ts +123 -0
  78. package/dist/api/design/furniture/index.d.ts.map +1 -0
  79. package/dist/api/design/index.d.ts +153 -0
  80. package/dist/api/design/index.d.ts.map +1 -0
  81. package/dist/api/design/lock.d.ts +41 -0
  82. package/dist/api/design/lock.d.ts.map +1 -0
  83. package/dist/api/design/materials/index.d.ts +297 -0
  84. package/dist/api/design/materials/index.d.ts.map +1 -0
  85. package/dist/api/design/query/geometry/index.d.ts +140 -0
  86. package/dist/api/design/query/geometry/index.d.ts.map +1 -0
  87. package/dist/api/design/query/index.d.ts +1011 -0
  88. package/dist/api/design/query/index.d.ts.map +1 -0
  89. package/dist/api/design/query/spaces.d.ts +221 -0
  90. package/dist/api/design/query/spaces.d.ts.map +1 -0
  91. package/dist/api/design/selection/index.d.ts +138 -0
  92. package/dist/api/design/selection/index.d.ts.map +1 -0
  93. package/dist/api/design/shared.d.ts +38 -0
  94. package/dist/api/design/shared.d.ts.map +1 -0
  95. package/dist/api/design/transform/index.d.ts +87 -0
  96. package/dist/api/design/transform/index.d.ts.map +1 -0
  97. package/dist/api/design/update/index.d.ts +178 -0
  98. package/dist/api/design/update/index.d.ts.map +1 -0
  99. package/dist/api/design/windows/index.d.ts +189 -0
  100. package/dist/api/design/windows/index.d.ts.map +1 -0
  101. package/dist/api/entity/buildableEnvelope.d.ts +261 -0
  102. package/dist/api/entity/buildableEnvelope.d.ts.map +1 -0
  103. package/dist/api/entity/department.d.ts +0 -98
  104. package/dist/api/entity/department.d.ts.map +1 -1
  105. package/dist/api/entity/index.d.ts +9 -9
  106. package/dist/api/entity/index.d.ts.map +1 -1
  107. package/dist/api/entity/referenceLine.d.ts +49 -106
  108. package/dist/api/entity/referenceLine.d.ts.map +1 -1
  109. package/dist/api/entity/space.d.ts +482 -249
  110. package/dist/api/entity/space.d.ts.map +1 -1
  111. package/dist/api/entity/story.d.ts +49 -39
  112. package/dist/api/entity/story.d.ts.map +1 -1
  113. package/dist/api/index.d.ts +17 -12
  114. package/dist/api/index.d.ts.map +1 -1
  115. package/dist/api/presentation/aiInspiration.d.ts +440 -0
  116. package/dist/api/presentation/aiInspiration.d.ts.map +1 -0
  117. package/dist/api/presentation/diagrams.d.ts +81 -0
  118. package/dist/api/presentation/diagrams.d.ts.map +1 -0
  119. package/dist/api/presentation/import.d.ts +113 -0
  120. package/dist/api/presentation/import.d.ts.map +1 -0
  121. package/dist/api/presentation/index.d.ts +46 -0
  122. package/dist/api/presentation/index.d.ts.map +1 -0
  123. package/dist/api/presentation/sheets.d.ts +176 -0
  124. package/dist/api/presentation/sheets.d.ts.map +1 -0
  125. package/dist/api/presentation/views.d.ts +296 -0
  126. package/dist/api/presentation/views.d.ts.map +1 -0
  127. package/dist/api/program/adjacency.d.ts +155 -0
  128. package/dist/api/program/adjacency.d.ts.map +1 -0
  129. package/dist/api/program/areas.d.ts +360 -0
  130. package/dist/api/program/areas.d.ts.map +1 -0
  131. package/dist/api/program/classification.d.ts +135 -0
  132. package/dist/api/program/classification.d.ts.map +1 -0
  133. package/dist/api/program/cores.d.ts +174 -0
  134. package/dist/api/program/cores.d.ts.map +1 -0
  135. package/dist/api/program/departments.d.ts +431 -0
  136. package/dist/api/program/departments.d.ts.map +1 -0
  137. package/dist/api/program/index.d.ts +69 -0
  138. package/dist/api/program/index.d.ts.map +1 -0
  139. package/dist/api/program/layout.d.ts +63 -0
  140. package/dist/api/program/layout.d.ts.map +1 -0
  141. package/dist/api/program/metrics.d.ts +108 -0
  142. package/dist/api/program/metrics.d.ts.map +1 -0
  143. package/dist/api/program/site.d.ts +367 -0
  144. package/dist/api/program/site.d.ts.map +1 -0
  145. package/dist/api/program/spreadsheet.d.ts +2041 -0
  146. package/dist/api/program/spreadsheet.d.ts.map +1 -0
  147. package/dist/handles.d.ts +138 -0
  148. package/dist/handles.d.ts.map +1 -0
  149. package/dist/host-utils.d.ts +7 -5
  150. package/dist/host-utils.d.ts.map +1 -1
  151. package/dist/index.cjs +4001 -904
  152. package/dist/index.cjs.map +1 -1
  153. package/dist/index.d.ts +1 -0
  154. package/dist/index.d.ts.map +1 -1
  155. package/dist/index.js +3392 -870
  156. package/dist/index.js.map +1 -1
  157. package/package.json +6 -2
  158. package/scripts/generate-manifest.mjs +193 -0
  159. package/scripts/generate-manifest.test.mjs +193 -0
  160. package/src/api/core/buildings.ts +485 -0
  161. package/src/api/core/comment/index.ts +258 -0
  162. package/src/api/core/geom/create/index.ts +293 -0
  163. package/src/api/core/geom/delete/index.ts +78 -0
  164. package/src/api/core/geom/index.ts +24 -23
  165. package/src/api/core/geom/query/arc.ts +169 -0
  166. package/src/api/core/geom/query/brep.ts +444 -0
  167. package/src/api/core/geom/query/circle.ts +404 -0
  168. package/src/api/core/geom/query/contour.ts +540 -0
  169. package/src/api/core/geom/query/curve.ts +1078 -0
  170. package/src/api/core/geom/query/edge.ts +130 -0
  171. package/src/api/core/geom/query/face.ts +403 -0
  172. package/src/api/core/geom/query/halfedge.ts +210 -0
  173. package/src/api/core/geom/query/index.ts +63 -0
  174. package/src/api/core/geom/query/profile.ts +473 -0
  175. package/src/api/core/geom/query/vertex.ts +205 -0
  176. package/src/api/core/geom/update/contour.ts +315 -0
  177. package/src/api/core/geom/update/curve.ts +209 -0
  178. package/src/api/core/geom/update/index.ts +29 -0
  179. package/src/api/core/geom/update/profile.ts +377 -0
  180. package/src/api/core/groups.ts +521 -0
  181. package/src/api/core/history/index.ts +84 -0
  182. package/src/api/core/index.ts +46 -1
  183. package/src/api/core/layers.ts +333 -0
  184. package/src/api/core/math/quat.ts +112 -235
  185. package/src/api/core/math/vec3.ts +124 -159
  186. package/src/api/core/project/index.ts +418 -0
  187. package/src/api/core/tags.ts +808 -0
  188. package/src/api/core/units/index.ts +164 -0
  189. package/src/api/core/zoom/index.ts +47 -0
  190. package/src/api/design/boolean/index.ts +179 -0
  191. package/src/api/design/create/index.ts +886 -0
  192. package/src/api/design/delete/index.ts +67 -0
  193. package/src/api/design/doors/index.ts +285 -0
  194. package/src/api/design/edit/index.ts +54 -0
  195. package/src/api/design/erase/index.ts +151 -0
  196. package/src/api/design/furniture/index.ts +130 -0
  197. package/src/api/design/index.ts +162 -0
  198. package/src/api/design/lock.ts +42 -0
  199. package/src/api/design/materials/index.ts +301 -0
  200. package/src/api/design/query/geometry/index.ts +166 -0
  201. package/src/api/design/query/index.ts +937 -0
  202. package/src/api/design/query/spaces.ts +132 -0
  203. package/src/api/design/selection/index.ts +144 -0
  204. package/src/api/design/shared.ts +40 -0
  205. package/src/api/design/transform/index.ts +93 -0
  206. package/src/api/design/update/index.ts +117 -0
  207. package/src/api/design/windows/index.ts +207 -0
  208. package/src/api/entity/buildableEnvelope.ts +318 -0
  209. package/src/api/entity/department.ts +0 -113
  210. package/src/api/entity/index.ts +9 -9
  211. package/src/api/entity/referenceLine.ts +50 -38
  212. package/src/api/entity/space.ts +285 -226
  213. package/src/api/entity/story.ts +53 -42
  214. package/src/api/index.ts +17 -12
  215. package/src/api/presentation/aiInspiration.ts +362 -0
  216. package/src/api/presentation/diagrams.ts +84 -0
  217. package/src/api/presentation/import.ts +112 -0
  218. package/src/api/presentation/index.ts +48 -0
  219. package/src/api/presentation/sheets.ts +198 -0
  220. package/src/api/presentation/views.ts +303 -0
  221. package/src/api/program/adjacency.ts +164 -0
  222. package/src/api/program/areas.ts +335 -0
  223. package/src/api/program/classification.ts +138 -0
  224. package/src/api/program/cores.ts +171 -0
  225. package/src/api/program/departments.ts +465 -0
  226. package/src/api/program/index.ts +71 -0
  227. package/src/api/program/layout.ts +68 -0
  228. package/src/api/program/metrics.ts +120 -0
  229. package/src/api/program/site.ts +326 -0
  230. package/src/api/program/spreadsheet.ts +2075 -0
  231. package/src/handles.ts +148 -0
  232. package/src/host-utils.ts +10 -6
  233. package/src/index.ts +1 -0
  234. package/dist/api/core/geom/arc.d.ts +0 -81
  235. package/dist/api/core/geom/arc.d.ts.map +0 -1
  236. package/dist/api/core/geom/curve.d.ts +0 -70
  237. package/dist/api/core/geom/curve.d.ts.map +0 -1
  238. package/dist/api/core/geom/line.d.ts +0 -56
  239. package/dist/api/core/geom/line.d.ts.map +0 -1
  240. package/dist/api/core/geom/profile.d.ts +0 -121
  241. package/dist/api/core/geom/profile.d.ts.map +0 -1
  242. package/dist/api/tools/copy.d.ts +0 -59
  243. package/dist/api/tools/copy.d.ts.map +0 -1
  244. package/dist/api/tools/index.d.ts +0 -33
  245. package/dist/api/tools/index.d.ts.map +0 -1
  246. package/dist/api/tools/material.d.ts +0 -51
  247. package/dist/api/tools/material.d.ts.map +0 -1
  248. package/dist/api/tools/offset.d.ts +0 -43
  249. package/dist/api/tools/offset.d.ts.map +0 -1
  250. package/dist/api/tools/selection.d.ts +0 -48
  251. package/dist/api/tools/selection.d.ts.map +0 -1
  252. package/dist/api/tools/transform.d.ts +0 -114
  253. package/dist/api/tools/transform.d.ts.map +0 -1
  254. package/dist/api/units/index.d.ts +0 -163
  255. package/dist/api/units/index.d.ts.map +0 -1
  256. package/src/api/core/geom/arc.ts +0 -70
  257. package/src/api/core/geom/curve.ts +0 -41
  258. package/src/api/core/geom/line.ts +0 -53
  259. package/src/api/core/geom/profile.ts +0 -94
  260. package/src/api/tools/copy.ts +0 -55
  261. package/src/api/tools/index.ts +0 -39
  262. package/src/api/tools/material.ts +0 -49
  263. package/src/api/tools/offset.ts +0 -43
  264. package/src/api/tools/selection.ts +0 -51
  265. package/src/api/tools/transform.ts +0 -117
  266. package/src/api/units/index.ts +0 -163
@@ -0,0 +1,130 @@
1
+ import * as z from "zod"
2
+ import { PluginApiReturn } from "../../../../types"
3
+ import { EdgeHandle, VertexHandle, HalfEdgeHandle, FaceHandle, CurveHandle } from "../../../../handles"
4
+
5
+ /**
6
+ * Edge queries — read a single BREP edge's topology and geometry (all-handle model,
7
+ * §11). An {@linkcode EdgeHandle} is minted by walking from a brep/face/vertex handle;
8
+ * it is session-ephemeral and goes stale on undo/redo/re-topologize.
9
+ *
10
+ * Accessed via `snaptrude.core.geom.query.edge`.
11
+ */
12
+ export abstract class PluginGeomQueryEdgeApi {
13
+ constructor() {}
14
+
15
+ /**
16
+ * Get the index of an edge within its brep.
17
+ * @param edge The edge to query
18
+ * @returns The index as a `number` (`-1` if unindexed)
19
+ *
20
+ * # Example
21
+ * ```ts
22
+ * const [wall] = await snaptrude.design.query.listWalls()
23
+ * const brep = await snaptrude.design.query.geometry.getBrep(wall)
24
+ * if (brep) {
25
+ * const [edge] = await snaptrude.core.geom.query.brep.listEdges(brep)
26
+ * const index = await snaptrude.core.geom.query.edge.getIndex(edge)
27
+ * }
28
+ * ```
29
+ */
30
+ public abstract getIndex(edge: EdgeHandle): PluginApiReturn<number>
31
+
32
+ /**
33
+ * Get the primary half-edge of an edge.
34
+ * @param edge The edge to query
35
+ * @returns The half-edge as a {@linkcode HalfEdgeHandle}, or `null` if uninitialized
36
+ *
37
+ * # Example
38
+ * ```ts
39
+ * const [wall] = await snaptrude.design.query.listWalls()
40
+ * const brep = await snaptrude.design.query.geometry.getBrep(wall)
41
+ * if (brep) {
42
+ * const [edge] = await snaptrude.core.geom.query.brep.listEdges(brep)
43
+ * const halfEdge = await snaptrude.core.geom.query.edge.getHalfEdge(edge)
44
+ * if (halfEdge) {
45
+ * const face = await snaptrude.core.geom.query.halfedge.getFace(halfEdge)
46
+ * }
47
+ * }
48
+ * ```
49
+ */
50
+ public abstract getHalfEdge(edge: EdgeHandle): PluginApiReturn<HalfEdgeHandle | null>
51
+
52
+ /**
53
+ * List the two endpoint vertices of an edge.
54
+ * @param edge The edge to query
55
+ * @returns The endpoints as {@linkcode VertexHandle}`[]`
56
+ *
57
+ * # Example
58
+ * ```ts
59
+ * const [wall] = await snaptrude.design.query.listWalls()
60
+ * const brep = await snaptrude.design.query.geometry.getBrep(wall)
61
+ * if (brep) {
62
+ * const [edge] = await snaptrude.core.geom.query.brep.listEdges(brep)
63
+ * const [a, b] = await snaptrude.core.geom.query.edge.listVertices(edge)
64
+ * const start = await snaptrude.core.geom.query.vertex.getPosition(brep, a)
65
+ * const end = await snaptrude.core.geom.query.vertex.getPosition(brep, b)
66
+ * }
67
+ * ```
68
+ */
69
+ public abstract listVertices(edge: EdgeHandle): PluginApiReturn<VertexHandle[]>
70
+
71
+ /**
72
+ * Get the underlying curve geometry of an edge (a line or arc).
73
+ * @param edge The edge to query
74
+ * @returns The curve as a {@linkcode CurveHandle}, or `null` if it is a circle or unset
75
+ *
76
+ * # Example
77
+ * ```ts
78
+ * const [wall] = await snaptrude.design.query.listWalls()
79
+ * const brep = await snaptrude.design.query.geometry.getBrep(wall)
80
+ * if (brep) {
81
+ * const [edge] = await snaptrude.core.geom.query.brep.listEdges(brep)
82
+ * const curve = await snaptrude.core.geom.query.edge.getCurve(edge)
83
+ * if (curve) {
84
+ * const length = await snaptrude.core.geom.query.curve.getLength(curve)
85
+ * }
86
+ * }
87
+ * ```
88
+ */
89
+ public abstract getCurve(edge: EdgeHandle): PluginApiReturn<CurveHandle | null>
90
+
91
+ /**
92
+ * List the faces bordering an edge (one or two).
93
+ * @param edge The edge to query
94
+ * @returns The bordering faces as {@linkcode FaceHandle}`[]`
95
+ *
96
+ * # Example
97
+ * ```ts
98
+ * const [wall] = await snaptrude.design.query.listWalls()
99
+ * const brep = await snaptrude.design.query.geometry.getBrep(wall)
100
+ * if (brep) {
101
+ * const [edge] = await snaptrude.core.geom.query.brep.listEdges(brep)
102
+ * const faces = await snaptrude.core.geom.query.edge.listFaces(edge)
103
+ * console.log(faces.length === 1 ? "boundary edge" : "interior edge")
104
+ * }
105
+ * ```
106
+ */
107
+ public abstract listFaces(edge: EdgeHandle): PluginApiReturn<FaceHandle[]>
108
+ }
109
+
110
+ const edgeArg = z.object({ edge: EdgeHandle })
111
+
112
+ /** Arguments for {@linkcode PluginGeomQueryEdgeApi.getIndex}. `{ edge: EdgeHandle }` */
113
+ export const PluginGeomQueryEdgeGetIndexArgs = edgeArg
114
+ export type PluginGeomQueryEdgeGetIndexArgs = z.infer<typeof PluginGeomQueryEdgeGetIndexArgs>
115
+
116
+ /** Arguments for {@linkcode PluginGeomQueryEdgeApi.getHalfEdge}. `{ edge: EdgeHandle }` */
117
+ export const PluginGeomQueryEdgeGetHalfEdgeArgs = edgeArg
118
+ export type PluginGeomQueryEdgeGetHalfEdgeArgs = z.infer<typeof PluginGeomQueryEdgeGetHalfEdgeArgs>
119
+
120
+ /** Arguments for {@linkcode PluginGeomQueryEdgeApi.listVertices}. `{ edge: EdgeHandle }` */
121
+ export const PluginGeomQueryEdgeListVerticesArgs = edgeArg
122
+ export type PluginGeomQueryEdgeListVerticesArgs = z.infer<typeof PluginGeomQueryEdgeListVerticesArgs>
123
+
124
+ /** Arguments for {@linkcode PluginGeomQueryEdgeApi.getCurve}. `{ edge: EdgeHandle }` */
125
+ export const PluginGeomQueryEdgeGetCurveArgs = edgeArg
126
+ export type PluginGeomQueryEdgeGetCurveArgs = z.infer<typeof PluginGeomQueryEdgeGetCurveArgs>
127
+
128
+ /** Arguments for {@linkcode PluginGeomQueryEdgeApi.listFaces}. `{ edge: EdgeHandle }` */
129
+ export const PluginGeomQueryEdgeListFacesArgs = edgeArg
130
+ export type PluginGeomQueryEdgeListFacesArgs = z.infer<typeof PluginGeomQueryEdgeListFacesArgs>
@@ -0,0 +1,403 @@
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
+ } from "../../../../handles"
11
+
12
+ /**
13
+ * Face queries — read the topology and boundary geometry of a single BREP face
14
+ * (all-handle model, §11). A {@linkcode FaceHandle} is minted by walking from a
15
+ * {@linkcode BrepHandle}; it is session-ephemeral and goes stale on
16
+ * undo/redo/re-topologize.
17
+ *
18
+ * Traversals mint fresh child topology handles; position reads return
19
+ * {@linkcode Vec3Components}. Holes are modelled per-loop: {@linkcode PluginGeomQueryFaceApi.listHoles}
20
+ * returns one seed half-edge per hole, and {@linkcode PluginGeomQueryFaceApi.listHoleHalfEdges}
21
+ * returns the full (flat) half-edge loop of one hole by index. No query mutates its inputs.
22
+ *
23
+ * Accessed via `snaptrude.core.geom.query.face`.
24
+ */
25
+ export abstract class PluginGeomQueryFaceApi {
26
+ constructor() {}
27
+
28
+ /**
29
+ * Get the index of a face within its brep.
30
+ * @param face The face to query
31
+ * @returns The index as a `number` (`-1` if unindexed)
32
+ *
33
+ * # Example
34
+ * ```ts
35
+ * const [wall] = await snaptrude.design.query.listWalls()
36
+ * const brep = await snaptrude.design.query.geometry.getBrep(wall)
37
+ * if (brep) {
38
+ * const [face] = await snaptrude.core.geom.query.brep.listFaces(brep)
39
+ * const index = await snaptrude.core.geom.query.face.getIndex(face)
40
+ * }
41
+ * ```
42
+ */
43
+ public abstract getIndex(face: FaceHandle): PluginApiReturn<number>
44
+
45
+ /**
46
+ * Get the raw (unmapped) material index of a face.
47
+ * @param face The face to query
48
+ * @returns The material index as a `number`
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 [face] = await snaptrude.core.geom.query.brep.listFaces(brep)
56
+ * const materialIndex = await snaptrude.core.geom.query.face.getMaterialIndex(face)
57
+ * }
58
+ * ```
59
+ */
60
+ public abstract getMaterialIndex(face: FaceHandle): PluginApiReturn<number>
61
+
62
+ /**
63
+ * Get a seed half-edge of a face's outer loop.
64
+ * @param face The face to query
65
+ * @returns The half-edge as a {@linkcode HalfEdgeHandle}, or `null` for a degenerate face
66
+ *
67
+ * # Example
68
+ * ```ts
69
+ * const [wall] = await snaptrude.design.query.listWalls()
70
+ * const brep = await snaptrude.design.query.geometry.getBrep(wall)
71
+ * if (brep) {
72
+ * const [face] = await snaptrude.core.geom.query.brep.listFaces(brep)
73
+ * const seed = await snaptrude.core.geom.query.face.getHalfEdge(face)
74
+ * if (seed) {
75
+ * const next = await snaptrude.core.geom.query.halfedge.getNext(seed)
76
+ * }
77
+ * }
78
+ * ```
79
+ */
80
+ public abstract getHalfEdge(face: FaceHandle): PluginApiReturn<HalfEdgeHandle | null>
81
+
82
+ /**
83
+ * List the edges of a face's outer loop.
84
+ * @param face The face to query
85
+ * @returns The edges as {@linkcode EdgeHandle}`[]`
86
+ *
87
+ * # Example
88
+ * ```ts
89
+ * const [wall] = await snaptrude.design.query.listWalls()
90
+ * const brep = await snaptrude.design.query.geometry.getBrep(wall)
91
+ * if (brep) {
92
+ * const [face] = await snaptrude.core.geom.query.brep.listFaces(brep)
93
+ * const edges = await snaptrude.core.geom.query.face.listEdges(face)
94
+ * }
95
+ * ```
96
+ */
97
+ public abstract listEdges(face: FaceHandle): PluginApiReturn<EdgeHandle[]>
98
+
99
+ /**
100
+ * List the half-edges of a face's outer loop.
101
+ * @param face The face to query
102
+ * @returns The half-edges as {@linkcode HalfEdgeHandle}`[]`
103
+ *
104
+ * # Example
105
+ * ```ts
106
+ * const [wall] = await snaptrude.design.query.listWalls()
107
+ * const brep = await snaptrude.design.query.geometry.getBrep(wall)
108
+ * if (brep) {
109
+ * const [face] = await snaptrude.core.geom.query.brep.listFaces(brep)
110
+ * const halfEdges = await snaptrude.core.geom.query.face.listHalfEdges(face)
111
+ * }
112
+ * ```
113
+ */
114
+ public abstract listHalfEdges(face: FaceHandle): PluginApiReturn<HalfEdgeHandle[]>
115
+
116
+ /**
117
+ * List the vertices of a face's outer loop.
118
+ * @param face The face to query
119
+ * @returns The vertices as {@linkcode VertexHandle}`[]`
120
+ *
121
+ * # Example
122
+ * ```ts
123
+ * const [wall] = await snaptrude.design.query.listWalls()
124
+ * const brep = await snaptrude.design.query.geometry.getBrep(wall)
125
+ * if (brep) {
126
+ * const [face] = await snaptrude.core.geom.query.brep.listFaces(brep)
127
+ * const vertices = await snaptrude.core.geom.query.face.listVertices(face)
128
+ * }
129
+ * ```
130
+ */
131
+ public abstract listVertices(face: FaceHandle): PluginApiReturn<VertexHandle[]>
132
+
133
+ /**
134
+ * List a face's holes as one seed half-edge per hole loop.
135
+ * @param face The face to query
136
+ * @returns The hole seeds as {@linkcode HalfEdgeHandle}`[]`
137
+ *
138
+ * # Example
139
+ * ```ts
140
+ * const [wall] = await snaptrude.design.query.listWalls()
141
+ * const brep = await snaptrude.design.query.geometry.getBrep(wall)
142
+ * if (brep) {
143
+ * const [face] = await snaptrude.core.geom.query.brep.listFaces(brep)
144
+ * const holeSeeds = await snaptrude.core.geom.query.face.listHoles(face)
145
+ * console.log("holes in this face:", holeSeeds.length)
146
+ * }
147
+ * ```
148
+ */
149
+ public abstract listHoles(face: FaceHandle): PluginApiReturn<HalfEdgeHandle[]>
150
+
151
+ /**
152
+ * Get the number of holes in a face.
153
+ * @param face The face to query
154
+ * @returns The hole count as a `number`
155
+ *
156
+ * # Example
157
+ * ```ts
158
+ * const [wall] = await snaptrude.design.query.listWalls()
159
+ * const brep = await snaptrude.design.query.geometry.getBrep(wall)
160
+ * if (brep) {
161
+ * const [face] = await snaptrude.core.geom.query.brep.listFaces(brep)
162
+ * const holeCount = await snaptrude.core.geom.query.face.getHoleCount(face)
163
+ * }
164
+ * ```
165
+ */
166
+ public abstract getHoleCount(face: FaceHandle): PluginApiReturn<number>
167
+
168
+ /**
169
+ * List the half-edge loop of one hole of a face (by hole index).
170
+ * @param face The face to query
171
+ * @param holeIndex Index of the hole (`0..getHoleCount-1`)
172
+ * @returns The hole's half-edges as {@linkcode HalfEdgeHandle}`[]` (`[]` if the index is out of range)
173
+ *
174
+ * # Example
175
+ * ```ts
176
+ * const [wall] = await snaptrude.design.query.listWalls()
177
+ * const brep = await snaptrude.design.query.geometry.getBrep(wall)
178
+ * if (brep) {
179
+ * const [face] = await snaptrude.core.geom.query.brep.listFaces(brep)
180
+ * const holeCount = await snaptrude.core.geom.query.face.getHoleCount(face)
181
+ * if (holeCount > 0) {
182
+ * const loop = await snaptrude.core.geom.query.face.listHoleHalfEdges(face, 0)
183
+ * }
184
+ * }
185
+ * ```
186
+ */
187
+ public abstract listHoleHalfEdges(
188
+ face: FaceHandle,
189
+ holeIndex: number,
190
+ ): PluginApiReturn<HalfEdgeHandle[]>
191
+
192
+ /**
193
+ * Test whether a face has any holes.
194
+ * @param face The face to query
195
+ * @returns `true` if the face has at least one hole, otherwise `false`
196
+ *
197
+ * @examplePrompt Does this face have any holes cut into it?
198
+ *
199
+ * # Example
200
+ * ```ts
201
+ * const [wall] = await snaptrude.design.query.listWalls()
202
+ * const brep = await snaptrude.design.query.geometry.getBrep(wall)
203
+ * if (brep) {
204
+ * const [face] = await snaptrude.core.geom.query.brep.listFaces(brep)
205
+ * const pierced = await snaptrude.core.geom.query.face.hasHoles(face)
206
+ * }
207
+ * ```
208
+ */
209
+ public abstract hasHoles(face: FaceHandle): PluginApiReturn<boolean>
210
+
211
+ /**
212
+ * Get the seed half-edge of the hole loop containing a given half-edge.
213
+ * @param face The face to query
214
+ * @param halfEdge The half-edge to locate
215
+ * @returns The hole seed as a {@linkcode HalfEdgeHandle}, or `null` if not in any hole
216
+ *
217
+ * # Example
218
+ * ```ts
219
+ * const [wall] = await snaptrude.design.query.listWalls()
220
+ * const brep = await snaptrude.design.query.geometry.getBrep(wall)
221
+ * if (brep) {
222
+ * const [face] = await snaptrude.core.geom.query.brep.listFaces(brep)
223
+ * const [he] = await snaptrude.core.geom.query.face.listHoleHalfEdges(face, 0)
224
+ * if (he) {
225
+ * const seed = await snaptrude.core.geom.query.face.getHoleContainingHalfEdge(face, he)
226
+ * }
227
+ * }
228
+ * ```
229
+ */
230
+ public abstract getHoleContainingHalfEdge(
231
+ face: FaceHandle,
232
+ halfEdge: HalfEdgeHandle,
233
+ ): PluginApiReturn<HalfEdgeHandle | null>
234
+
235
+ /**
236
+ * List the positions of a face's outer-loop vertices (needs the parent brep for coordinates).
237
+ * @param face The face to query
238
+ * @param brep The parent brep (source of vertex coordinates)
239
+ * @returns The positions as {@linkcode Vec3Components}`[]`
240
+ *
241
+ * @examplePrompt What are the corner coordinates of this face?
242
+ * @examplePrompt Get the boundary points of the selected face
243
+ *
244
+ * # Example
245
+ * ```ts
246
+ * const [wall] = await snaptrude.design.query.listWalls()
247
+ * const brep = await snaptrude.design.query.geometry.getBrep(wall)
248
+ * if (brep) {
249
+ * const [face] = await snaptrude.core.geom.query.brep.listFaces(brep)
250
+ * const corners = await snaptrude.core.geom.query.face.listVertexPositions(face, brep)
251
+ * for (const p of corners) console.log(p.x, p.y, p.z)
252
+ * }
253
+ * ```
254
+ */
255
+ public abstract listVertexPositions(
256
+ face: FaceHandle,
257
+ brep: BrepHandle,
258
+ ): PluginApiReturn<Vec3Components[]>
259
+
260
+ /**
261
+ * List the tessellated boundary points of a face's outer loop (arcs sampled,
262
+ * sense-corrected). Not cardinality-equal to {@linkcode PluginGeomQueryFaceApi.listVertexPositions}.
263
+ * @param face The face to query
264
+ * @returns The boundary points as {@linkcode Vec3Components}`[]`
265
+ *
266
+ * @examplePrompt Trace the outline of this face including its curved edges
267
+ *
268
+ * # Example
269
+ * ```ts
270
+ * const [wall] = await snaptrude.design.query.listWalls()
271
+ * const brep = await snaptrude.design.query.geometry.getBrep(wall)
272
+ * if (brep) {
273
+ * const [face] = await snaptrude.core.geom.query.brep.listFaces(brep)
274
+ * const outline = await snaptrude.core.geom.query.face.listVertexPositionsWithCurves(face)
275
+ * }
276
+ * ```
277
+ */
278
+ public abstract listVertexPositionsWithCurves(
279
+ face: FaceHandle,
280
+ ): PluginApiReturn<Vec3Components[]>
281
+
282
+ /**
283
+ * List the faces adjacent to a face (sharing an edge). Boundary edges are skipped.
284
+ * @param face The face to query
285
+ * @returns The adjacent faces as {@linkcode FaceHandle}`[]`
286
+ *
287
+ * @examplePrompt Which faces are next to this one?
288
+ * @examplePrompt Find the faces that share an edge with the selected face
289
+ *
290
+ * # Example
291
+ * ```ts
292
+ * const [mass] = await snaptrude.design.query.listMasses()
293
+ * const brep = await snaptrude.design.query.geometry.getBrep(mass)
294
+ * if (brep) {
295
+ * const [face] = await snaptrude.core.geom.query.brep.listFaces(brep)
296
+ * const neighbours = await snaptrude.core.geom.query.face.listAdjacentFaces(face)
297
+ * }
298
+ * ```
299
+ */
300
+ public abstract listAdjacentFaces(face: FaceHandle): PluginApiReturn<FaceHandle[]>
301
+ }
302
+
303
+ const faceArg = z.object({ face: FaceHandle })
304
+
305
+ /** Arguments for {@linkcode PluginGeomQueryFaceApi.getIndex}. `{ face: FaceHandle }` */
306
+ export const PluginGeomQueryFaceGetIndexArgs = faceArg
307
+ export type PluginGeomQueryFaceGetIndexArgs = z.infer<typeof PluginGeomQueryFaceGetIndexArgs>
308
+
309
+ /** Arguments for {@linkcode PluginGeomQueryFaceApi.getMaterialIndex}. `{ face: FaceHandle }` */
310
+ export const PluginGeomQueryFaceGetMaterialIndexArgs = faceArg
311
+ export type PluginGeomQueryFaceGetMaterialIndexArgs = z.infer<
312
+ typeof PluginGeomQueryFaceGetMaterialIndexArgs
313
+ >
314
+
315
+ /** Arguments for {@linkcode PluginGeomQueryFaceApi.getHalfEdge}. `{ face: FaceHandle }` */
316
+ export const PluginGeomQueryFaceGetHalfEdgeArgs = faceArg
317
+ export type PluginGeomQueryFaceGetHalfEdgeArgs = z.infer<typeof PluginGeomQueryFaceGetHalfEdgeArgs>
318
+
319
+ /** Arguments for {@linkcode PluginGeomQueryFaceApi.listEdges}. `{ face: FaceHandle }` */
320
+ export const PluginGeomQueryFaceListEdgesArgs = faceArg
321
+ export type PluginGeomQueryFaceListEdgesArgs = z.infer<typeof PluginGeomQueryFaceListEdgesArgs>
322
+
323
+ /** Arguments for {@linkcode PluginGeomQueryFaceApi.listHalfEdges}. `{ face: FaceHandle }` */
324
+ export const PluginGeomQueryFaceListHalfEdgesArgs = faceArg
325
+ export type PluginGeomQueryFaceListHalfEdgesArgs = z.infer<
326
+ typeof PluginGeomQueryFaceListHalfEdgesArgs
327
+ >
328
+
329
+ /** Arguments for {@linkcode PluginGeomQueryFaceApi.listVertices}. `{ face: FaceHandle }` */
330
+ export const PluginGeomQueryFaceListVerticesArgs = faceArg
331
+ export type PluginGeomQueryFaceListVerticesArgs = z.infer<typeof PluginGeomQueryFaceListVerticesArgs>
332
+
333
+ /** Arguments for {@linkcode PluginGeomQueryFaceApi.listHoles}. `{ face: FaceHandle }` */
334
+ export const PluginGeomQueryFaceListHolesArgs = faceArg
335
+ export type PluginGeomQueryFaceListHolesArgs = z.infer<typeof PluginGeomQueryFaceListHolesArgs>
336
+
337
+ /** Arguments for {@linkcode PluginGeomQueryFaceApi.getHoleCount}. `{ face: FaceHandle }` */
338
+ export const PluginGeomQueryFaceGetHoleCountArgs = faceArg
339
+ export type PluginGeomQueryFaceGetHoleCountArgs = z.infer<typeof PluginGeomQueryFaceGetHoleCountArgs>
340
+
341
+ /**
342
+ * Arguments for {@linkcode PluginGeomQueryFaceApi.listHoleHalfEdges}.
343
+ *
344
+ * | Property | Type | Description |
345
+ * |---|---|---|
346
+ * | `face` | {@linkcode FaceHandle} | The face to query |
347
+ * | `holeIndex` | `number` | Index of the hole (`0..getHoleCount-1`) |
348
+ */
349
+ export const PluginGeomQueryFaceListHoleHalfEdgesArgs = z.object({
350
+ face: FaceHandle,
351
+ holeIndex: z.number(),
352
+ })
353
+ export type PluginGeomQueryFaceListHoleHalfEdgesArgs = z.infer<
354
+ typeof PluginGeomQueryFaceListHoleHalfEdgesArgs
355
+ >
356
+
357
+ /** Arguments for {@linkcode PluginGeomQueryFaceApi.hasHoles}. `{ face: FaceHandle }` */
358
+ export const PluginGeomQueryFaceHasHolesArgs = faceArg
359
+ export type PluginGeomQueryFaceHasHolesArgs = z.infer<typeof PluginGeomQueryFaceHasHolesArgs>
360
+
361
+ /**
362
+ * Arguments for {@linkcode PluginGeomQueryFaceApi.getHoleContainingHalfEdge}.
363
+ *
364
+ * | Property | Type | Description |
365
+ * |---|---|---|
366
+ * | `face` | {@linkcode FaceHandle} | The face to query |
367
+ * | `halfEdge` | {@linkcode HalfEdgeHandle} | The half-edge to locate |
368
+ */
369
+ export const PluginGeomQueryFaceGetHoleContainingHalfEdgeArgs = z.object({
370
+ face: FaceHandle,
371
+ halfEdge: HalfEdgeHandle,
372
+ })
373
+ export type PluginGeomQueryFaceGetHoleContainingHalfEdgeArgs = z.infer<
374
+ typeof PluginGeomQueryFaceGetHoleContainingHalfEdgeArgs
375
+ >
376
+
377
+ /**
378
+ * Arguments for {@linkcode PluginGeomQueryFaceApi.listVertexPositions}.
379
+ *
380
+ * | Property | Type | Description |
381
+ * |---|---|---|
382
+ * | `face` | {@linkcode FaceHandle} | The face to query |
383
+ * | `brep` | {@linkcode BrepHandle} | The parent brep (source of vertex coordinates) |
384
+ */
385
+ export const PluginGeomQueryFaceListVertexPositionsArgs = z.object({
386
+ face: FaceHandle,
387
+ brep: BrepHandle,
388
+ })
389
+ export type PluginGeomQueryFaceListVertexPositionsArgs = z.infer<
390
+ typeof PluginGeomQueryFaceListVertexPositionsArgs
391
+ >
392
+
393
+ /** Arguments for {@linkcode PluginGeomQueryFaceApi.listVertexPositionsWithCurves}. `{ face: FaceHandle }` */
394
+ export const PluginGeomQueryFaceListVertexPositionsWithCurvesArgs = faceArg
395
+ export type PluginGeomQueryFaceListVertexPositionsWithCurvesArgs = z.infer<
396
+ typeof PluginGeomQueryFaceListVertexPositionsWithCurvesArgs
397
+ >
398
+
399
+ /** Arguments for {@linkcode PluginGeomQueryFaceApi.listAdjacentFaces}. `{ face: FaceHandle }` */
400
+ export const PluginGeomQueryFaceListAdjacentFacesArgs = faceArg
401
+ export type PluginGeomQueryFaceListAdjacentFacesArgs = z.infer<
402
+ typeof PluginGeomQueryFaceListAdjacentFacesArgs
403
+ >