@itwin/core-backend 5.1.0-dev.4 → 5.1.0-dev.41

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 (284) hide show
  1. package/CHANGELOG.md +109 -1
  2. package/lib/cjs/BackendHubAccess.d.ts +1 -1
  3. package/lib/cjs/BackendHubAccess.js +1 -1
  4. package/lib/cjs/BackendHubAccess.js.map +1 -1
  5. package/lib/cjs/BisCoreSchema.js +1 -1
  6. package/lib/cjs/BisCoreSchema.js.map +1 -1
  7. package/lib/cjs/BriefcaseManager.d.ts +10 -2
  8. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  9. package/lib/cjs/BriefcaseManager.js +12 -0
  10. package/lib/cjs/BriefcaseManager.js.map +1 -1
  11. package/lib/cjs/Category.d.ts +4 -4
  12. package/lib/cjs/Category.js +4 -4
  13. package/lib/cjs/Category.js.map +1 -1
  14. package/lib/cjs/ChangesetECAdaptor.d.ts +67 -8
  15. package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
  16. package/lib/cjs/ChangesetECAdaptor.js +248 -33
  17. package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
  18. package/lib/cjs/ClassRegistry.d.ts +1 -1
  19. package/lib/cjs/ClassRegistry.js +1 -1
  20. package/lib/cjs/ClassRegistry.js.map +1 -1
  21. package/lib/cjs/CloudSqlite.js +1 -1
  22. package/lib/cjs/CloudSqlite.js.map +1 -1
  23. package/lib/cjs/CodeSpecs.d.ts +1 -1
  24. package/lib/cjs/CodeSpecs.js +1 -1
  25. package/lib/cjs/CodeSpecs.js.map +1 -1
  26. package/lib/cjs/DisplayStyle.d.ts +4 -4
  27. package/lib/cjs/DisplayStyle.js +3 -3
  28. package/lib/cjs/DisplayStyle.js.map +1 -1
  29. package/lib/cjs/ECDb.d.ts +4 -4
  30. package/lib/cjs/ECDb.d.ts.map +1 -1
  31. package/lib/cjs/ECDb.js +4 -4
  32. package/lib/cjs/ECDb.js.map +1 -1
  33. package/lib/cjs/ECSqlStatement.d.ts +15 -6
  34. package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
  35. package/lib/cjs/ECSqlStatement.js +18 -4
  36. package/lib/cjs/ECSqlStatement.js.map +1 -1
  37. package/lib/cjs/Element.d.ts +51 -51
  38. package/lib/cjs/Element.js +51 -51
  39. package/lib/cjs/Element.js.map +1 -1
  40. package/lib/cjs/ElementAspect.d.ts +8 -8
  41. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  42. package/lib/cjs/ElementAspect.js +8 -8
  43. package/lib/cjs/ElementAspect.js.map +1 -1
  44. package/lib/cjs/Entity.d.ts +3 -3
  45. package/lib/cjs/Entity.js +2 -2
  46. package/lib/cjs/Entity.js.map +1 -1
  47. package/lib/cjs/ExportGraphics.d.ts +54 -8
  48. package/lib/cjs/ExportGraphics.d.ts.map +1 -1
  49. package/lib/cjs/ExportGraphics.js +158 -59
  50. package/lib/cjs/ExportGraphics.js.map +1 -1
  51. package/lib/cjs/GeographicCRSServices.d.ts +6 -2
  52. package/lib/cjs/GeographicCRSServices.d.ts.map +1 -1
  53. package/lib/cjs/GeographicCRSServices.js +1 -1
  54. package/lib/cjs/GeographicCRSServices.js.map +1 -1
  55. package/lib/cjs/IModelDb.d.ts +23 -21
  56. package/lib/cjs/IModelDb.d.ts.map +1 -1
  57. package/lib/cjs/IModelDb.js +57 -31
  58. package/lib/cjs/IModelDb.js.map +1 -1
  59. package/lib/cjs/IModelElementCloneContext.d.ts +1 -1
  60. package/lib/cjs/IModelElementCloneContext.d.ts.map +1 -1
  61. package/lib/cjs/IModelElementCloneContext.js +1 -1
  62. package/lib/cjs/IModelElementCloneContext.js.map +1 -1
  63. package/lib/cjs/IModelHost.d.ts +2 -2
  64. package/lib/cjs/IModelHost.js +2 -2
  65. package/lib/cjs/IModelHost.js.map +1 -1
  66. package/lib/cjs/Material.d.ts +1 -1
  67. package/lib/cjs/Material.js +1 -1
  68. package/lib/cjs/Material.js.map +1 -1
  69. package/lib/cjs/Model.d.ts +22 -22
  70. package/lib/cjs/Model.js +22 -22
  71. package/lib/cjs/Model.js.map +1 -1
  72. package/lib/cjs/SQLiteDb.d.ts +1 -1
  73. package/lib/cjs/SQLiteDb.js +1 -1
  74. package/lib/cjs/SQLiteDb.js.map +1 -1
  75. package/lib/cjs/SqliteStatement.d.ts +1 -1
  76. package/lib/cjs/SqliteStatement.d.ts.map +1 -1
  77. package/lib/cjs/SqliteStatement.js +1 -1
  78. package/lib/cjs/SqliteStatement.js.map +1 -1
  79. package/lib/cjs/Texture.d.ts +1 -1
  80. package/lib/cjs/Texture.js +1 -1
  81. package/lib/cjs/Texture.js.map +1 -1
  82. package/lib/cjs/TxnManager.d.ts +4 -4
  83. package/lib/cjs/TxnManager.js +1 -1
  84. package/lib/cjs/TxnManager.js.map +1 -1
  85. package/lib/cjs/ViewDefinition.d.ts +40 -14
  86. package/lib/cjs/ViewDefinition.d.ts.map +1 -1
  87. package/lib/cjs/ViewDefinition.js +42 -14
  88. package/lib/cjs/ViewDefinition.js.map +1 -1
  89. package/lib/cjs/annotations/FrameGeometry.d.ts +52 -0
  90. package/lib/cjs/annotations/FrameGeometry.d.ts.map +1 -0
  91. package/lib/cjs/annotations/FrameGeometry.js +250 -0
  92. package/lib/cjs/annotations/FrameGeometry.js.map +1 -0
  93. package/lib/cjs/{TextAnnotationElement.d.ts → annotations/TextAnnotationElement.d.ts} +6 -11
  94. package/lib/cjs/annotations/TextAnnotationElement.d.ts.map +1 -0
  95. package/lib/cjs/{TextAnnotationElement.js → annotations/TextAnnotationElement.js} +20 -26
  96. package/lib/cjs/annotations/TextAnnotationElement.js.map +1 -0
  97. package/lib/cjs/annotations/TextAnnotationGeometry.d.ts +31 -0
  98. package/lib/cjs/annotations/TextAnnotationGeometry.d.ts.map +1 -0
  99. package/lib/cjs/annotations/TextAnnotationGeometry.js +83 -0
  100. package/lib/cjs/annotations/TextAnnotationGeometry.js.map +1 -0
  101. package/lib/cjs/annotations/TextBlockGeometry.d.ts +16 -0
  102. package/lib/cjs/annotations/TextBlockGeometry.d.ts.map +1 -0
  103. package/lib/cjs/{TextAnnotationGeometry.js → annotations/TextBlockGeometry.js} +11 -68
  104. package/lib/cjs/annotations/TextBlockGeometry.js.map +1 -0
  105. package/lib/cjs/{TextAnnotationLayout.d.ts → annotations/TextBlockLayout.d.ts} +19 -7
  106. package/lib/cjs/annotations/TextBlockLayout.d.ts.map +1 -0
  107. package/lib/cjs/{TextAnnotationLayout.js → annotations/TextBlockLayout.js} +19 -7
  108. package/lib/cjs/annotations/TextBlockLayout.js.map +1 -0
  109. package/lib/cjs/core-backend.d.ts +5 -3
  110. package/lib/cjs/core-backend.d.ts.map +1 -1
  111. package/lib/cjs/core-backend.js +25 -6
  112. package/lib/cjs/core-backend.js.map +1 -1
  113. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +1 -1
  114. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +1 -1
  115. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  116. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +2 -2
  117. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  118. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +1 -1
  119. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +1 -1
  120. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  121. package/lib/esm/BackendHubAccess.d.ts +1 -1
  122. package/lib/esm/BackendHubAccess.js +1 -1
  123. package/lib/esm/BackendHubAccess.js.map +1 -1
  124. package/lib/esm/BisCoreSchema.js +1 -1
  125. package/lib/esm/BisCoreSchema.js.map +1 -1
  126. package/lib/esm/BriefcaseManager.d.ts +10 -2
  127. package/lib/esm/BriefcaseManager.d.ts.map +1 -1
  128. package/lib/esm/BriefcaseManager.js +12 -0
  129. package/lib/esm/BriefcaseManager.js.map +1 -1
  130. package/lib/esm/Category.d.ts +4 -4
  131. package/lib/esm/Category.js +4 -4
  132. package/lib/esm/Category.js.map +1 -1
  133. package/lib/esm/ChangesetECAdaptor.d.ts +67 -8
  134. package/lib/esm/ChangesetECAdaptor.d.ts.map +1 -1
  135. package/lib/esm/ChangesetECAdaptor.js +248 -33
  136. package/lib/esm/ChangesetECAdaptor.js.map +1 -1
  137. package/lib/esm/ClassRegistry.d.ts +1 -1
  138. package/lib/esm/ClassRegistry.js +1 -1
  139. package/lib/esm/ClassRegistry.js.map +1 -1
  140. package/lib/esm/CloudSqlite.js +1 -1
  141. package/lib/esm/CloudSqlite.js.map +1 -1
  142. package/lib/esm/CodeSpecs.d.ts +1 -1
  143. package/lib/esm/CodeSpecs.js +1 -1
  144. package/lib/esm/CodeSpecs.js.map +1 -1
  145. package/lib/esm/DisplayStyle.d.ts +4 -4
  146. package/lib/esm/DisplayStyle.js +3 -3
  147. package/lib/esm/DisplayStyle.js.map +1 -1
  148. package/lib/esm/ECDb.d.ts +4 -4
  149. package/lib/esm/ECDb.d.ts.map +1 -1
  150. package/lib/esm/ECDb.js +4 -4
  151. package/lib/esm/ECDb.js.map +1 -1
  152. package/lib/esm/ECSqlStatement.d.ts +15 -6
  153. package/lib/esm/ECSqlStatement.d.ts.map +1 -1
  154. package/lib/esm/ECSqlStatement.js +18 -4
  155. package/lib/esm/ECSqlStatement.js.map +1 -1
  156. package/lib/esm/Element.d.ts +51 -51
  157. package/lib/esm/Element.js +51 -51
  158. package/lib/esm/Element.js.map +1 -1
  159. package/lib/esm/ElementAspect.d.ts +8 -8
  160. package/lib/esm/ElementAspect.d.ts.map +1 -1
  161. package/lib/esm/ElementAspect.js +8 -8
  162. package/lib/esm/ElementAspect.js.map +1 -1
  163. package/lib/esm/Entity.d.ts +3 -3
  164. package/lib/esm/Entity.js +2 -2
  165. package/lib/esm/Entity.js.map +1 -1
  166. package/lib/esm/ExportGraphics.d.ts +54 -8
  167. package/lib/esm/ExportGraphics.d.ts.map +1 -1
  168. package/lib/esm/ExportGraphics.js +156 -58
  169. package/lib/esm/ExportGraphics.js.map +1 -1
  170. package/lib/esm/GeographicCRSServices.d.ts +6 -2
  171. package/lib/esm/GeographicCRSServices.d.ts.map +1 -1
  172. package/lib/esm/GeographicCRSServices.js +1 -1
  173. package/lib/esm/GeographicCRSServices.js.map +1 -1
  174. package/lib/esm/IModelDb.d.ts +23 -21
  175. package/lib/esm/IModelDb.d.ts.map +1 -1
  176. package/lib/esm/IModelDb.js +58 -32
  177. package/lib/esm/IModelDb.js.map +1 -1
  178. package/lib/esm/IModelElementCloneContext.d.ts +1 -1
  179. package/lib/esm/IModelElementCloneContext.d.ts.map +1 -1
  180. package/lib/esm/IModelElementCloneContext.js +1 -1
  181. package/lib/esm/IModelElementCloneContext.js.map +1 -1
  182. package/lib/esm/IModelHost.d.ts +2 -2
  183. package/lib/esm/IModelHost.js +2 -2
  184. package/lib/esm/IModelHost.js.map +1 -1
  185. package/lib/esm/Material.d.ts +1 -1
  186. package/lib/esm/Material.js +1 -1
  187. package/lib/esm/Material.js.map +1 -1
  188. package/lib/esm/Model.d.ts +22 -22
  189. package/lib/esm/Model.js +22 -22
  190. package/lib/esm/Model.js.map +1 -1
  191. package/lib/esm/SQLiteDb.d.ts +1 -1
  192. package/lib/esm/SQLiteDb.js +1 -1
  193. package/lib/esm/SQLiteDb.js.map +1 -1
  194. package/lib/esm/SqliteStatement.d.ts +1 -1
  195. package/lib/esm/SqliteStatement.d.ts.map +1 -1
  196. package/lib/esm/SqliteStatement.js +1 -1
  197. package/lib/esm/SqliteStatement.js.map +1 -1
  198. package/lib/esm/Texture.d.ts +1 -1
  199. package/lib/esm/Texture.js +1 -1
  200. package/lib/esm/Texture.js.map +1 -1
  201. package/lib/esm/TxnManager.d.ts +4 -4
  202. package/lib/esm/TxnManager.js +1 -1
  203. package/lib/esm/TxnManager.js.map +1 -1
  204. package/lib/esm/ViewDefinition.d.ts +40 -14
  205. package/lib/esm/ViewDefinition.d.ts.map +1 -1
  206. package/lib/esm/ViewDefinition.js +42 -14
  207. package/lib/esm/ViewDefinition.js.map +1 -1
  208. package/lib/esm/annotations/FrameGeometry.d.ts +52 -0
  209. package/lib/esm/annotations/FrameGeometry.d.ts.map +1 -0
  210. package/lib/esm/annotations/FrameGeometry.js +245 -0
  211. package/lib/esm/annotations/FrameGeometry.js.map +1 -0
  212. package/lib/esm/{TextAnnotationElement.d.ts → annotations/TextAnnotationElement.d.ts} +6 -11
  213. package/lib/esm/annotations/TextAnnotationElement.d.ts.map +1 -0
  214. package/lib/esm/{TextAnnotationElement.js → annotations/TextAnnotationElement.js} +22 -28
  215. package/lib/esm/annotations/TextAnnotationElement.js.map +1 -0
  216. package/lib/esm/annotations/TextAnnotationGeometry.d.ts +31 -0
  217. package/lib/esm/annotations/TextAnnotationGeometry.d.ts.map +1 -0
  218. package/lib/esm/annotations/TextAnnotationGeometry.js +80 -0
  219. package/lib/esm/annotations/TextAnnotationGeometry.js.map +1 -0
  220. package/lib/esm/annotations/TextBlockGeometry.d.ts +16 -0
  221. package/lib/esm/annotations/TextBlockGeometry.d.ts.map +1 -0
  222. package/lib/esm/{TextAnnotationGeometry.js → annotations/TextBlockGeometry.js} +11 -68
  223. package/lib/esm/annotations/TextBlockGeometry.js.map +1 -0
  224. package/lib/esm/{TextAnnotationLayout.d.ts → annotations/TextBlockLayout.d.ts} +19 -7
  225. package/lib/esm/annotations/TextBlockLayout.d.ts.map +1 -0
  226. package/lib/esm/{TextAnnotationLayout.js → annotations/TextBlockLayout.js} +19 -7
  227. package/lib/esm/annotations/TextBlockLayout.js.map +1 -0
  228. package/lib/esm/core-backend.d.ts +5 -3
  229. package/lib/esm/core-backend.d.ts.map +1 -1
  230. package/lib/esm/core-backend.js +25 -3
  231. package/lib/esm/core-backend.js.map +1 -1
  232. package/lib/esm/rpc-impl/IModelReadRpcImpl.d.ts +1 -1
  233. package/lib/esm/rpc-impl/IModelReadRpcImpl.js +1 -1
  234. package/lib/esm/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  235. package/lib/esm/rpc-impl/RpcBriefcaseUtility.d.ts +2 -2
  236. package/lib/esm/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  237. package/lib/esm/rpc-impl/SnapshotIModelRpcImpl.d.ts +1 -1
  238. package/lib/esm/rpc-impl/SnapshotIModelRpcImpl.js +1 -1
  239. package/lib/esm/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  240. package/lib/esm/test/TestUtils.d.ts +1 -1
  241. package/lib/esm/test/TestUtils.d.ts.map +1 -1
  242. package/lib/esm/test/TestUtils.js +1 -1
  243. package/lib/esm/test/TestUtils.js.map +1 -1
  244. package/lib/esm/test/annotations/TextAnnotation.test.js +190 -1025
  245. package/lib/esm/test/annotations/TextAnnotation.test.js.map +1 -1
  246. package/lib/esm/test/annotations/TextBlock.test.d.ts +2 -0
  247. package/lib/esm/test/annotations/TextBlock.test.d.ts.map +1 -0
  248. package/lib/esm/test/annotations/TextBlock.test.js +969 -0
  249. package/lib/esm/test/annotations/TextBlock.test.js.map +1 -0
  250. package/lib/esm/test/ecdb/ECDb.test.js +29 -8
  251. package/lib/esm/test/ecdb/ECDb.test.js.map +1 -1
  252. package/lib/esm/test/ecdb/ECSqlStatement.test.js +192 -0
  253. package/lib/esm/test/ecdb/ECSqlStatement.test.js.map +1 -1
  254. package/lib/esm/test/imodel/IModel.test.js +228 -5
  255. package/lib/esm/test/imodel/IModel.test.js.map +1 -1
  256. package/lib/esm/test/misc/GeoServices.test.js +23 -9
  257. package/lib/esm/test/misc/GeoServices.test.js.map +1 -1
  258. package/lib/esm/test/standalone/ChangesetReader.test.js +451 -136
  259. package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
  260. package/lib/esm/test/standalone/ExportGraphics.test.js +53 -1
  261. package/lib/esm/test/standalone/ExportGraphics.test.js.map +1 -1
  262. package/lib/esm/test/standalone/GeometryStream.test.js +49 -1
  263. package/lib/esm/test/standalone/GeometryStream.test.js.map +1 -1
  264. package/lib/esm/test/standalone/IModelLimits.test.d.ts +2 -0
  265. package/lib/esm/test/standalone/IModelLimits.test.d.ts.map +1 -0
  266. package/lib/esm/test/standalone/IModelLimits.test.js +103 -0
  267. package/lib/esm/test/standalone/IModelLimits.test.js.map +1 -0
  268. package/lib/esm/test/standalone/SnapshotDb.test.js +19 -1
  269. package/lib/esm/test/standalone/SnapshotDb.test.js.map +1 -1
  270. package/package.json +13 -13
  271. package/lib/cjs/TextAnnotationElement.d.ts.map +0 -1
  272. package/lib/cjs/TextAnnotationElement.js.map +0 -1
  273. package/lib/cjs/TextAnnotationGeometry.d.ts +0 -32
  274. package/lib/cjs/TextAnnotationGeometry.d.ts.map +0 -1
  275. package/lib/cjs/TextAnnotationGeometry.js.map +0 -1
  276. package/lib/cjs/TextAnnotationLayout.d.ts.map +0 -1
  277. package/lib/cjs/TextAnnotationLayout.js.map +0 -1
  278. package/lib/esm/TextAnnotationElement.d.ts.map +0 -1
  279. package/lib/esm/TextAnnotationElement.js.map +0 -1
  280. package/lib/esm/TextAnnotationGeometry.d.ts +0 -32
  281. package/lib/esm/TextAnnotationGeometry.d.ts.map +0 -1
  282. package/lib/esm/TextAnnotationGeometry.js.map +0 -1
  283. package/lib/esm/TextAnnotationLayout.d.ts.map +0 -1
  284. package/lib/esm/TextAnnotationLayout.js.map +0 -1
@@ -0,0 +1,245 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /** @packageDocumentation
6
+ * @module ElementGeometry
7
+ */
8
+ import { BackgroundFill, ColorDef, FillDisplay } from "@itwin/core-common";
9
+ import { Angle, AngleSweep, Arc3d, LineString3d, Loop, Path, Point3d, Vector2d } from "@itwin/core-geometry";
10
+ /**
11
+ * Based on the frame style, this method will construct and append [[GeometryParams]] (for line style) and a [[Loop]] (for the frame shape) to the builder.
12
+ * @param builder that will be appended to in place
13
+ * @param category to which the frame belongs, used for the [[GeometryParams]].
14
+ * @param frame
15
+ * @param range to enclose with the frame
16
+ * @param transform that transform the range to world coordinates
17
+ * @returns `true` if any geometry was appended to the builder
18
+ * @beta
19
+ */
20
+ export function appendFrameToBuilder(builder, frame, range, transform, geomParams) {
21
+ if (undefined === frame.shape || frame.shape === "none") {
22
+ return false;
23
+ }
24
+ const params = geomParams.clone();
25
+ if (frame.fill === undefined) {
26
+ params.fillDisplay = FillDisplay.Never;
27
+ }
28
+ else if (frame.fill === "background") {
29
+ params.backgroundFill = BackgroundFill.Solid;
30
+ params.fillDisplay = FillDisplay.Blanking;
31
+ }
32
+ else if (frame.fill !== "subcategory") {
33
+ params.fillColor = ColorDef.fromJSON(frame.fill);
34
+ params.lineColor = params.fillColor;
35
+ params.fillDisplay = FillDisplay.Blanking;
36
+ }
37
+ if (frame.border !== "subcategory") {
38
+ params.lineColor = ColorDef.fromJSON(frame.border);
39
+ params.weight = frame.borderWeight;
40
+ }
41
+ const frameGeometry = computeFrame({ frame: frame.shape, range, transform });
42
+ if (!builder.appendGeometryParamsChange(params) || !builder.appendGeometryQuery(frameGeometry)) {
43
+ return false;
44
+ }
45
+ // The tile generator does not produce an outline for shapes with blanking fill. We must add the outline separately.
46
+ if (params.fillDisplay === FillDisplay.Blanking) {
47
+ const outlineParams = params.clone();
48
+ outlineParams.fillDisplay = FillDisplay.Never;
49
+ if (!builder.appendGeometryParamsChange(outlineParams) || !builder.appendGeometryQuery(frameGeometry)) {
50
+ return false;
51
+ }
52
+ }
53
+ return true;
54
+ }
55
+ /**
56
+ * Computes the frame geometry based on the provided frame shape and range.
57
+ * @returns a [Loop]($geometry) or [Path]($geometry) (if it's just a line) that represents the frame geometry
58
+ * @beta
59
+ */
60
+ export function computeFrame(args) {
61
+ switch (args.frame) {
62
+ case "line": return computeLine(args.range, args.transform);
63
+ case "rectangle": return computeRectangle(args.range, args.transform);
64
+ case "circle": return computeCircle(args.range, args.transform);
65
+ case "equilateralTriangle": return computeTriangle(args.range, args.transform);
66
+ case "diamond": return computeDiamond(args.range, args.transform);
67
+ case "square": return computeSquare(args.range, args.transform);
68
+ case "pentagon": return computePolygon(5, args.range, args.transform, 90);
69
+ case "hexagon": return computePolygon(6, args.range, args.transform);
70
+ case "octagon": return computePolygon(8, args.range, args.transform, 180 / 8); // or pi/8 in radians
71
+ case "capsule": return computeCapsule(args.range, args.transform);
72
+ case "roundedRectangle": return computeRoundedRectangle(args.range, args.transform);
73
+ default: return computeRectangle(args.range, args.transform);
74
+ }
75
+ }
76
+ /**
77
+ * Computes points along the edges of the frame geometry based on the provided frame shape, range, and interval factors.
78
+ * These can be used for snapping or attaching leaders.
79
+ * @returns an array of [[Point3d]] that represent the points along the edges of the frame geometry. Returns `undefined` if the loop created by `computeFrame` is empty.
80
+ * @beta
81
+ */
82
+ export function computeIntervalPoints({ frame, range, transform, lineIntervalFactor = 0.5, arcIntervalFactor = 0.25 }) {
83
+ const points = [];
84
+ const curves = computeFrame({ frame, range, transform }).collectCurvePrimitives(undefined, false, true);
85
+ curves.forEach((curve) => {
86
+ const end = curve instanceof Arc3d ? arcIntervalFactor : lineIntervalFactor;
87
+ for (let interval = 0; interval <= 1; interval += end) {
88
+ points.push(curve.fractionToPoint(interval));
89
+ }
90
+ });
91
+ return points;
92
+ }
93
+ /** Line - currently just adds an underline. Once we have leaders, this method may change. */
94
+ const computeLine = (range, transform) => {
95
+ const points = [Point3d.create(range.low.x, range.low.y), Point3d.create(range.high.x, range.low.y)];
96
+ const frame = LineString3d.createPoints(points);
97
+ return Path.create(frame.cloneTransformed(transform));
98
+ };
99
+ /** Rectangle - simplest frame */
100
+ const computeRectangle = (range, transform) => {
101
+ const points = range.corners3d(true);
102
+ const frame = LineString3d.createPoints(points);
103
+ return Loop.create(frame.cloneTransformed(transform));
104
+ };
105
+ /** Rounded Rectangle: each corner will be turned into an arc with the radius of the arc being the @param radiusFactor * the height (yLength) of the range */
106
+ const computeRoundedRectangle = (range, transform, radiusFactor = 0.25) => {
107
+ const radius = range.yLength() * radiusFactor * Math.sqrt(2);
108
+ // We're going to circumscribe the range with our rounded edges. The corners of the range will fall on 45 degree angles.
109
+ const radiusOffsetFactor = range.yLength() * radiusFactor;
110
+ // These values are the origins of the circles
111
+ const inLeft = range.low.x + radiusOffsetFactor;
112
+ const inRight = range.high.x - radiusOffsetFactor;
113
+ const inBottom = range.low.y + radiusOffsetFactor;
114
+ const inTop = range.high.y - radiusOffsetFactor;
115
+ // These values exist on the circles
116
+ const exLeft = inLeft - radius;
117
+ const exRight = inRight + radius;
118
+ const exBottom = inBottom - radius;
119
+ const exTop = inTop + radius;
120
+ const q1 = AngleSweep.createStartEndDegrees(0, 90);
121
+ const q2 = AngleSweep.createStartEndDegrees(90, 180);
122
+ const q3 = AngleSweep.createStartEndDegrees(180, 270);
123
+ const q4 = AngleSweep.createStartEndDegrees(270, 360);
124
+ const curves = [
125
+ LineString3d.create([Point3d.create(inLeft, exTop), Point3d.create(inRight, exTop)]), // top
126
+ Arc3d.createXY(Point3d.create(inLeft, inTop), radius, q2), // top left
127
+ LineString3d.create([Point3d.create(exLeft, inBottom), Point3d.create(exLeft, inTop)]), // left
128
+ Arc3d.createXY(Point3d.create(inLeft, inBottom), radius, q3), // bottom left
129
+ LineString3d.create([Point3d.create(inLeft, exBottom), Point3d.create(inRight, exBottom)]), // bottom
130
+ Arc3d.createXY(Point3d.create(inRight, inBottom), radius, q4), // bottom right
131
+ LineString3d.create([Point3d.create(exRight, inBottom), Point3d.create(exRight, inTop)]), // right
132
+ Arc3d.createXY(Point3d.create(inRight, inTop), radius, q1), // top right
133
+ ];
134
+ return Loop.createArray(curves.map((curve) => curve.cloneTransformed(transform)));
135
+ };
136
+ /** Circle */
137
+ const computeCircle = (range, transform) => {
138
+ const radius = range.low.distance(range.high) / 2;
139
+ const frame = Arc3d.createXY(Point3d.createFrom(range.center), radius);
140
+ return Loop.create(frame.cloneTransformed(transform));
141
+ };
142
+ /** Equilateral Triangle */
143
+ const computeTriangle = (range, transform) => {
144
+ const xLength = range.xLength();
145
+ const yLength = range.yLength();
146
+ const center = range.center;
147
+ const points = [];
148
+ const magnitude = (xLength > yLength) ? (xLength * Math.sqrt(3) + yLength) / 2 : (yLength * Math.sqrt(3) + xLength) / 2;
149
+ const v1 = Vector2d.create(0, magnitude);
150
+ const vectors = [
151
+ v1, // top
152
+ v1.rotateXY(Angle.createDegrees(120)), // left
153
+ v1.rotateXY(Angle.createDegrees(240)), // right
154
+ v1 // top
155
+ ];
156
+ vectors.forEach((v) => {
157
+ points.push(Point3d.create(center.x + v.x, center.y + v.y));
158
+ });
159
+ const frame = LineString3d.createPoints(points);
160
+ return Loop.create(frame.cloneTransformed(transform));
161
+ };
162
+ /** Diamond (square rotated 45 degrees) */
163
+ const computeDiamond = (range, transform) => {
164
+ const offset = (range.xLength() + range.yLength()) / 2;
165
+ const center = range.center;
166
+ const points = [
167
+ Point3d.createFrom({ x: center.x, y: center.y + offset }), // top
168
+ Point3d.createFrom({ x: center.x + offset, y: center.y }), // right
169
+ Point3d.createFrom({ x: center.x, y: center.y - offset }), // bottom
170
+ Point3d.createFrom({ x: center.x - offset, y: center.y }), // left
171
+ Point3d.createFrom({ x: center.x, y: center.y + offset }), // top
172
+ ];
173
+ const frame = LineString3d.createPoints(points);
174
+ return Loop.create(frame.cloneTransformed(transform));
175
+ };
176
+ /** Square */
177
+ const computeSquare = (range, transform) => {
178
+ // Extend range
179
+ const xLength = range.xLength() / 2;
180
+ const yLength = range.yLength() / 2;
181
+ const center = range.center;
182
+ if (xLength > yLength) {
183
+ range.extendPoint({ x: center.x, y: center.y + xLength });
184
+ range.extendPoint({ x: center.x, y: center.y - xLength });
185
+ }
186
+ else {
187
+ range.extendPoint({ x: center.x + yLength, y: center.y });
188
+ range.extendPoint({ x: center.x - yLength, y: center.y });
189
+ }
190
+ const points = range.corners3d(true);
191
+ const frame = LineString3d.createPoints(points);
192
+ return Loop.create(frame.cloneTransformed(transform));
193
+ };
194
+ /** Capsule (or pill shape) */
195
+ const computeCapsule = (range, transform) => {
196
+ const height = range.yLength();
197
+ const radius = height * (Math.sqrt(2) / 2);
198
+ // We're going to circumscribe the range with our rounded edges. The corners of the range will fall on 45 degree angles.
199
+ const radiusOffsetFactor = height / 2;
200
+ // These values are the origins of the circles
201
+ const inLeft = range.low.x + radiusOffsetFactor;
202
+ const inRight = range.high.x - radiusOffsetFactor;
203
+ const inBottom = range.low.y + radiusOffsetFactor;
204
+ const inTop = range.high.y - radiusOffsetFactor;
205
+ // These values exist on the circles
206
+ const exBottom = inBottom - radius;
207
+ const exTop = inTop + radius;
208
+ const leftHalfCircle = AngleSweep.createStartEndDegrees(90, 270);
209
+ const rightHalfCircle = AngleSweep.createStartEndDegrees(-90, 90);
210
+ const curves = [
211
+ LineString3d.create([Point3d.create(inLeft, exTop), Point3d.create(inRight, exTop)]), // top
212
+ Arc3d.createXY(Point3d.create(inLeft, range.center.y), radius, leftHalfCircle), // left
213
+ LineString3d.create([Point3d.create(inLeft, exBottom), Point3d.create(inRight, exBottom)]), // bottom
214
+ Arc3d.createXY(Point3d.create(inRight, range.center.y), radius, rightHalfCircle), // right
215
+ ];
216
+ return Loop.createArray(curves.map((curve) => curve.cloneTransformed(transform)));
217
+ };
218
+ /** Regular polygon with n sides: note, this a generic method that can be used to create any polygon, but the frame will not be as tightly encapsulating. */
219
+ const computePolygon = (n, range, transform, angleOffset = 0) => {
220
+ // These are math terms: cspell:ignore inradius circumradius
221
+ if (n < 3)
222
+ throw new Error("A polygon must have at least 3 sides.");
223
+ // We're assuming the polygon is a regular polygon with `n` sides.
224
+ // The center of the polygon is the center of the range.
225
+ const center = range.center;
226
+ // The inradius is the distance from the center to the midpoint of each side of the polygon. On our range, this coincides with the distance from the center to one of its corners.
227
+ const inradius = range.low.distance(range.high) / 2;
228
+ // The circumradius is the distance from the center to each vertex of the polygon.
229
+ const circumradius = inradius / Math.cos(Math.PI / n);
230
+ // The exterior angles add up to 360 degrees.
231
+ const angleIncrement = 360 / n;
232
+ const vertices = [];
233
+ // Add a point for each vertex
234
+ for (let i = 0; i < n; i++) {
235
+ const angle = Angle.createDegrees(i * angleIncrement + angleOffset);
236
+ const vector = Vector2d.createPolar(circumradius, angle);
237
+ vertices.push(Point3d.create(center.x + vector.x, center.y + vector.y));
238
+ }
239
+ // Close the polygon
240
+ vertices.push(vertices[0]);
241
+ // Finally compute the loop!
242
+ const frame = LineString3d.createPoints(vertices);
243
+ return Loop.create(frame.cloneTransformed(transform));
244
+ };
245
+ //# sourceMappingURL=FrameGeometry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FrameGeometry.js","sourceRoot":"","sources":["../../../src/annotations/FrameGeometry.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAmB,WAAW,EAAiE,MAAM,oBAAoB,CAAC;AAC3J,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAsB,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEjI;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAgC,EAAE,KAA0B,EAAE,KAAc,EAAE,SAAoB,EAAE,UAA0B;IACjK,IAAI,SAAS,KAAK,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,KAAK,MAAM,EAAE,CAAC;QACxD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,EAAE,CAAC;IAElC,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,CAAC,WAAW,GAAG,WAAW,CAAC,KAAK,CAAC;IACzC,CAAC;SAAM,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QACvC,MAAM,CAAC,cAAc,GAAG,cAAc,CAAC,KAAK,CAAC;QAC7C,MAAM,CAAC,WAAW,GAAG,W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,CAAC;IAClD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;AACxD,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ElementGeometry\n */\n\n\nimport { BackgroundFill, ColorDef, ElementGeometry, FillDisplay, GeometryParams, TextAnnotationFrameShape, TextFrameStyleProps } from \"@itwin/core-common\";\nimport { Angle, AngleSweep, Arc3d, LineString3d, Loop, Path, Point3d, Range2d, Transform, Vector2d } from \"@itwin/core-geometry\";\n\n/**\n * Based on the frame style, this method will construct and append [[GeometryParams]] (for line style) and a [[Loop]] (for the frame shape) to the builder.\n * @param builder that will be appended to in place\n * @param category to which the frame belongs, used for the [[GeometryParams]].\n * @param frame\n * @param range to enclose with the frame\n * @param transform that transform the range to world coordinates\n * @returns `true` if any geometry was appended to the builder\n* @beta\n */\nexport function appendFrameToBuilder(builder: ElementGeometry.Builder, frame: TextFrameStyleProps, range: Range2d, transform: Transform, geomParams: GeometryParams): boolean {\n if (undefined === frame.shape || frame.shape === \"none\") {\n return false;\n }\n\n const params = geomParams.clone();\n\n if (frame.fill === undefined) {\n params.fillDisplay = FillDisplay.Never;\n } else if (frame.fill === \"background\") {\n params.backgroundFill = BackgroundFill.Solid;\n params.fillDisplay = FillDisplay.Blanking;\n } else if (frame.fill !== \"subcategory\") {\n params.fillColor = ColorDef.fromJSON(frame.fill);\n params.lineColor = params.fillColor;\n params.fillDisplay = FillDisplay.Blanking;\n }\n\n if (frame.border !== \"subcategory\") {\n params.lineColor = ColorDef.fromJSON(frame.border);\n params.weight = frame.borderWeight;\n }\n\n const frameGeometry = computeFrame({ frame: frame.shape, range, transform });\n if (!builder.appendGeometryParamsChange(params) || !builder.appendGeometryQuery(frameGeometry)) {\n return false;\n }\n\n // The tile generator does not produce an outline for shapes with blanking fill. We must add the outline separately.\n if (params.fillDisplay === FillDisplay.Blanking) {\n const outlineParams = params.clone();\n outlineParams.fillDisplay = FillDisplay.Never;\n if (!builder.appendGeometryParamsChange(outlineParams) || !builder.appendGeometryQuery(frameGeometry)) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Arguments for the [[computeFrame]] method.\n * @beta\n */\nexport interface ComputeFrameArgs {\n /** Frame shape to be calculated */\n frame: Exclude<TextAnnotationFrameShape, \"none\">;\n /** Range to be enclosed */\n range: Range2d;\n /** Transform that translates and rotates the range to world coordinates */\n transform: Transform;\n}\n\n/**\n * Computes the frame geometry based on the provided frame shape and range.\n * @returns a [Loop]($geometry) or [Path]($geometry) (if it's just a line) that represents the frame geometry\n * @beta\n */\nexport function computeFrame(args: ComputeFrameArgs): Loop | Path {\n switch (args.frame) {\n case \"line\": return computeLine(args.range, args.transform);\n case \"rectangle\": return computeRectangle(args.range, args.transform);\n case \"circle\": return computeCircle(args.range, args.transform);\n case \"equilateralTriangle\": return computeTriangle(args.range, args.transform);\n case \"diamond\": return computeDiamond(args.range, args.transform);\n case \"square\": return computeSquare(args.range, args.transform);\n case \"pentagon\": return computePolygon(5, args.range, args.transform, 90);\n case \"hexagon\": return computePolygon(6, args.range, args.transform);\n case \"octagon\": return computePolygon(8, args.range, args.transform, 180 / 8); // or pi/8 in radians\n case \"capsule\": return computeCapsule(args.range, args.transform);\n case \"roundedRectangle\": return computeRoundedRectangle(args.range, args.transform);\n default: return computeRectangle(args.range, args.transform);\n }\n}\n\n/**\n * Arguments for the [[computeIntervalPoints]] method.\n * @beta\n */\nexport interface ComputeIntervalPointsArgs extends ComputeFrameArgs {\n /** A factor applied to divide each straight edge. A value of 1 will place a single point on each vertex. */\n lineIntervalFactor?: number;\n /** A factor applied to divide each straight edge. A value of 1 will place a single point on each vertex. */\n arcIntervalFactor?: number;\n}\n\n/**\n * Computes points along the edges of the frame geometry based on the provided frame shape, range, and interval factors.\n * These can be used for snapping or attaching leaders.\n * @returns an array of [[Point3d]] that represent the points along the edges of the frame geometry. Returns `undefined` if the loop created by `computeFrame` is empty.\n * @beta\n */\nexport function computeIntervalPoints({ frame, range, transform, lineIntervalFactor = 0.5, arcIntervalFactor = 0.25 }: ComputeIntervalPointsArgs): Point3d[] | undefined {\n const points: Point3d[] = [];\n const curves = computeFrame({ frame, range, transform }).collectCurvePrimitives(undefined, false, true);\n\n curves.forEach((curve) => {\n const end = curve instanceof Arc3d ? arcIntervalFactor : lineIntervalFactor;\n for (let interval = 0; interval <= 1; interval += end) {\n points.push(curve.fractionToPoint(interval));\n }\n });\n return points;\n}\n\n/** Line - currently just adds an underline. Once we have leaders, this method may change. */\nconst computeLine = (range: Range2d, transform: Transform): Path => {\n const points = [Point3d.create(range.low.x, range.low.y), Point3d.create(range.high.x, range.low.y)];\n const frame = LineString3d.createPoints(points);\n\n return Path.create(frame.cloneTransformed(transform));\n}\n\n/** Rectangle - simplest frame */\nconst computeRectangle = (range: Range2d, transform: Transform): Loop => {\n const points = range.corners3d(true);\n const frame = LineString3d.createPoints(points);\n\n return Loop.create(frame.cloneTransformed(transform));\n}\n\n/** Rounded Rectangle: each corner will be turned into an arc with the radius of the arc being the @param radiusFactor * the height (yLength) of the range */\nconst computeRoundedRectangle = (range: Range2d, transform: Transform, radiusFactor: number = 0.25): Loop => {\n const radius = range.yLength() * radiusFactor * Math.sqrt(2);\n // We're going to circumscribe the range with our rounded edges. The corners of the range will fall on 45 degree angles.\n const radiusOffsetFactor = range.yLength() * radiusFactor;\n\n // These values are the origins of the circles\n const inLeft = range.low.x + radiusOffsetFactor;\n const inRight = range.high.x - radiusOffsetFactor;\n const inBottom = range.low.y + radiusOffsetFactor;\n const inTop = range.high.y - radiusOffsetFactor\n\n // These values exist on the circles\n const exLeft = inLeft - radius;\n const exRight = inRight + radius;\n const exBottom = inBottom - radius;\n const exTop = inTop + radius;\n\n const q1 = AngleSweep.createStartEndDegrees(0, 90);\n const q2 = AngleSweep.createStartEndDegrees(90, 180);\n const q3 = AngleSweep.createStartEndDegrees(180, 270);\n const q4 = AngleSweep.createStartEndDegrees(270, 360);\n\n\n const curves = [\n LineString3d.create([Point3d.create(inLeft, exTop), Point3d.create(inRight, exTop)]), // top\n Arc3d.createXY(Point3d.create(inLeft, inTop), radius, q2), // top left\n LineString3d.create([Point3d.create(exLeft, inBottom), Point3d.create(exLeft, inTop)]), // left\n Arc3d.createXY(Point3d.create(inLeft, inBottom), radius, q3), // bottom left\n LineString3d.create([Point3d.create(inLeft, exBottom), Point3d.create(inRight, exBottom)]), // bottom\n Arc3d.createXY(Point3d.create(inRight, inBottom), radius, q4), // bottom right\n LineString3d.create([Point3d.create(exRight, inBottom), Point3d.create(exRight, inTop)]), // right\n Arc3d.createXY(Point3d.create(inRight, inTop), radius, q1), // top right\n ];\n\n return Loop.createArray(curves.map((curve) => curve.cloneTransformed(transform)))\n}\n\n\n/** Circle */\nconst computeCircle = (range: Range2d, transform: Transform): Loop => {\n const radius = range.low.distance(range.high) / 2;\n const frame = Arc3d.createXY(Point3d.createFrom(range.center), radius);\n return Loop.create(frame.cloneTransformed(transform));\n}\n\n/** Equilateral Triangle */\nconst computeTriangle = (range: Range2d, transform: Transform): Loop => {\n\n const xLength = range.xLength();\n const yLength = range.yLength();\n const center = range.center;\n const points: Point3d[] = [];\n\n const magnitude = (xLength > yLength) ? (xLength * Math.sqrt(3) + yLength) / 2 : (yLength * Math.sqrt(3) + xLength) / 2;\n\n const v1 = Vector2d.create(0, magnitude);\n const vectors = [\n v1, // top\n v1.rotateXY(Angle.createDegrees(120)), // left\n v1.rotateXY(Angle.createDegrees(240)), // right\n v1 // top\n ];\n\n vectors.forEach((v) => {\n points.push(Point3d.create(center.x + v.x, center.y + v.y));\n });\n\n const frame = LineString3d.createPoints(points);\n\n return Loop.create(frame.cloneTransformed(transform));\n}\n\n/** Diamond (square rotated 45 degrees) */\nconst computeDiamond = (range: Range2d, transform: Transform): Loop => {\n const offset = (range.xLength() + range.yLength()) / 2;\n const center = range.center;\n\n const points = [\n Point3d.createFrom({ x: center.x, y: center.y + offset }), // top\n Point3d.createFrom({ x: center.x + offset, y: center.y }), // right\n Point3d.createFrom({ x: center.x, y: center.y - offset }), // bottom\n Point3d.createFrom({ x: center.x - offset, y: center.y }), // left\n Point3d.createFrom({ x: center.x, y: center.y + offset }), // top\n ];\n\n const frame = LineString3d.createPoints(points);\n\n return Loop.create(frame.cloneTransformed(transform));\n}\n\n/** Square */\nconst computeSquare = (range: Range2d, transform: Transform): Loop => {\n\n // Extend range\n const xLength = range.xLength() / 2;\n const yLength = range.yLength() / 2;\n const center = range.center;\n if (xLength > yLength) {\n range.extendPoint({ x: center.x, y: center.y + xLength });\n range.extendPoint({ x: center.x, y: center.y - xLength });\n } else {\n range.extendPoint({ x: center.x + yLength, y: center.y });\n range.extendPoint({ x: center.x - yLength, y: center.y });\n }\n\n const points = range.corners3d(true);\n const frame = LineString3d.createPoints(points);\n\n return Loop.create(frame.cloneTransformed(transform));\n}\n\n/** Capsule (or pill shape) */\nconst computeCapsule = (range: Range2d, transform: Transform): Loop => {\n const height = range.yLength();\n const radius = height * (Math.sqrt(2) / 2);\n\n // We're going to circumscribe the range with our rounded edges. The corners of the range will fall on 45 degree angles.\n const radiusOffsetFactor = height / 2;\n\n // These values are the origins of the circles\n const inLeft = range.low.x + radiusOffsetFactor;\n const inRight = range.high.x - radiusOffsetFactor;\n const inBottom = range.low.y + radiusOffsetFactor;\n const inTop = range.high.y - radiusOffsetFactor\n\n // These values exist on the circles\n const exBottom = inBottom - radius;\n const exTop = inTop + radius;\n\n const leftHalfCircle = AngleSweep.createStartEndDegrees(90, 270);\n const rightHalfCircle = AngleSweep.createStartEndDegrees(-90, 90);\n\n const curves = [\n LineString3d.create([Point3d.create(inLeft, exTop), Point3d.create(inRight, exTop)]), // top\n Arc3d.createXY(Point3d.create(inLeft, range.center.y), radius, leftHalfCircle), // left\n LineString3d.create([Point3d.create(inLeft, exBottom), Point3d.create(inRight, exBottom)]), // bottom\n Arc3d.createXY(Point3d.create(inRight, range.center.y), radius, rightHalfCircle), // right\n ];\n\n return Loop.createArray(curves.map((curve) => curve.cloneTransformed(transform)));\n}\n\n/** Regular polygon with n sides: note, this a generic method that can be used to create any polygon, but the frame will not be as tightly encapsulating. */\nconst computePolygon = (n: number, range: Range2d, transform: Transform, angleOffset: number = 0): Loop => {\n // These are math terms: cspell:ignore inradius circumradius\n if (n < 3) throw new Error(\"A polygon must have at least 3 sides.\");\n\n // We're assuming the polygon is a regular polygon with `n` sides.\n // The center of the polygon is the center of the range.\n const center = range.center;\n // The inradius is the distance from the center to the midpoint of each side of the polygon. On our range, this coincides with the distance from the center to one of its corners.\n const inradius = range.low.distance(range.high) / 2;\n // The circumradius is the distance from the center to each vertex of the polygon.\n const circumradius = inradius / Math.cos(Math.PI / n);\n\n // The exterior angles add up to 360 degrees.\n const angleIncrement = 360 / n;\n const vertices: Point3d[] = [];\n\n // Add a point for each vertex\n for (let i = 0; i < n; i++) {\n const angle = Angle.createDegrees(i * angleIncrement + angleOffset);\n const vector = Vector2d.createPolar(circumradius, angle);\n vertices.push(Point3d.create(center.x + vector.x, center.y + vector.y));\n }\n\n // Close the polygon\n vertices.push(vertices[0]);\n\n // Finally compute the loop!\n const frame = LineString3d.createPoints(vertices);\n return Loop.create(frame.cloneTransformed(transform));\n};"]}
@@ -2,13 +2,12 @@
2
2
  * @module Elements
3
3
  */
4
4
  import { TextAnnotation, TextAnnotation2dProps, TextAnnotation3dProps } from "@itwin/core-common";
5
- import { IModelDb } from "./IModelDb";
6
- import { AnnotationElement2d, GraphicalElement3d } from "./Element";
7
- import { Id64String } from "@itwin/core-bentley";
5
+ import { IModelDb } from "../IModelDb";
6
+ import { AnnotationElement2d, GraphicalElement3d } from "../Element";
8
7
  /** An element that displays textual content within a 2d model.
9
8
  * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.
10
9
  * @see [[setAnnotation]] to change the textual content.
11
- * @public
10
+ * @public @preview
12
11
  */
13
12
  export declare class TextAnnotation2d extends AnnotationElement2d {
14
13
  /** @internal */
@@ -23,15 +22,13 @@ export declare class TextAnnotation2d extends AnnotationElement2d {
23
22
  /** Change the textual content, updating the element's geometry and placement accordingly.
24
23
  * @see [[getAnnotation]] to extract the current annotation.
25
24
  * @param annotation The new annotation
26
- * @param subCategory If specified, the subcategory on which to define the geometry; otherwise, the default subcategory of the element's category is used.
27
- * @returns true if the annotation was successfully updated.
28
25
  */
29
- setAnnotation(annotation: TextAnnotation, subCategory?: Id64String): boolean;
26
+ setAnnotation(annotation: TextAnnotation): void;
30
27
  }
31
28
  /** An element that displays textual content within a 3d model.
32
29
  * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.
33
30
  * @see [[setAnnotation]] to change the textual content.
34
- * @public
31
+ * @public @preview
35
32
  */
36
33
  export declare class TextAnnotation3d extends GraphicalElement3d {
37
34
  /** @internal */
@@ -46,9 +43,7 @@ export declare class TextAnnotation3d extends GraphicalElement3d {
46
43
  /** Change the textual content, updating the element's geometry and placement accordingly.
47
44
  * @see [[getAnnotation]] to extract the current annotation.
48
45
  * @param annotation The new annotation
49
- * @param subCategory If specified, the subcategory on which to define the geometry; otherwise, the default subcategory of the element's category is used.
50
- * @returns true if the annotation was successfully updated.
51
46
  */
52
- setAnnotation(annotation: TextAnnotation, subCategory?: Id64String): boolean;
47
+ setAnnotation(annotation: TextAnnotation): void;
53
48
  }
54
49
  //# sourceMappingURL=TextAnnotationElement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextAnnotationElement.d.ts","sourceRoot":"","sources":["../../../src/annotations/TextAnnotationElement.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAiE,cAAc,EAAE,qBAAqB,EAAE,qBAAqB,EAAuB,MAAM,oBAAoB,CAAC;AACtL,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAcrE;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,mBAAmB;IACvD,gBAAgB;IAChB,WAA2B,SAAS,IAAI,MAAM,CAA+B;IAC7E,SAAS,aAAa,KAAK,EAAE,qBAAqB,EAAE,MAAM,EAAE,QAAQ;WAEtD,QAAQ,CAAC,KAAK,EAAE,qBAAqB,EAAE,MAAM,EAAE,QAAQ,GAAG,gBAAgB;IAIxE,MAAM,IAAI,qBAAqB;IAO/C;;OAEG;IACI,aAAa,IAAI,cAAc,GAAG,SAAS;IAKlD;;;OAGG;IACI,aAAa,CAAC,UAAU,EAAE,cAAc;CAGhD;AAED;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,kBAAkB;IACtD,gBAAgB;IAChB,WAA2B,SAAS,IAAI,MAAM,CAA+B;IAC7E,SAAS,aAAa,KAAK,EAAE,qBAAqB,EAAE,MAAM,EAAE,QAAQ;WAEtD,QAAQ,CAAC,KAAK,EAAE,qBAAqB,EAAE,MAAM,EAAE,QAAQ,GAAG,gBAAgB;IAIxE,MAAM,IAAI,qBAAqB;IAO/C;;OAEG;IACI,aAAa,IAAI,cAAc,GAAG,SAAS;IAKlD;;;OAGG;IACI,aAAa,CAAC,UAAU,EAAE,cAAc;CAGhD"}
@@ -5,27 +5,21 @@
5
5
  /** @packageDocumentation
6
6
  * @module Elements
7
7
  */
8
- import { GeometryParams, GeometryStreamBuilder, TextAnnotation } from "@itwin/core-common";
9
- import { AnnotationElement2d, GraphicalElement3d } from "./Element";
10
- import { produceTextAnnotationGeometry } from "./TextAnnotationGeometry";
11
- function updateAnnotation(element, annotation, subCategory) {
12
- const builder = new GeometryStreamBuilder();
13
- const params = new GeometryParams(element.category, subCategory);
14
- if (!builder.appendGeometryParamsChange(params)) {
15
- return false;
16
- }
17
- const props = produceTextAnnotationGeometry({ iModel: element.iModel, annotation });
18
- if (!builder.appendTextBlock(props)) {
19
- return false;
20
- }
21
- element.geom = builder.geometryStream;
22
- element.jsonProperties.annotation = annotation.toJSON();
23
- return true;
8
+ import { ElementGeometry, TextAnnotation } from "@itwin/core-common";
9
+ import { AnnotationElement2d, GraphicalElement3d } from "../Element";
10
+ import { layoutTextBlock } from "./TextBlockLayout";
11
+ import { appendTextAnnotationGeometry } from "./TextAnnotationGeometry";
12
+ function getElementGeometryBuilderParams(iModel, _placementProps, annotationProps, categoryId, _subCategory) {
13
+ const textBlock = TextAnnotation.fromJSON(annotationProps).textBlock;
14
+ const layout = layoutTextBlock({ iModel, textBlock });
15
+ const builder = new ElementGeometry.Builder();
16
+ appendTextAnnotationGeometry({ layout, annotationProps, builder, categoryId });
17
+ return { entryArray: builder.entries };
24
18
  }
25
19
  /** An element that displays textual content within a 2d model.
26
20
  * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.
27
21
  * @see [[setAnnotation]] to change the textual content.
28
- * @public
22
+ * @public @preview
29
23
  */
30
24
  export class TextAnnotation2d extends AnnotationElement2d {
31
25
  /** @internal */
@@ -35,7 +29,9 @@ export class TextAnnotation2d extends AnnotationElement2d {
35
29
  return new TextAnnotation2d(props, iModel);
36
30
  }
37
31
  toJSON() {
38
- return super.toJSON();
32
+ const props = super.toJSON();
33
+ props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.placement, this.jsonProperties.annotation, this.category);
34
+ return props;
39
35
  }
40
36
  /** Extract the textual content, if present.
41
37
  * @see [[setAnnotation]] to change it.
@@ -47,17 +43,15 @@ export class TextAnnotation2d extends AnnotationElement2d {
47
43
  /** Change the textual content, updating the element's geometry and placement accordingly.
48
44
  * @see [[getAnnotation]] to extract the current annotation.
49
45
  * @param annotation The new annotation
50
- * @param subCategory If specified, the subcategory on which to define the geometry; otherwise, the default subcategory of the element's category is used.
51
- * @returns true if the annotation was successfully updated.
52
46
  */
53
- setAnnotation(annotation, subCategory) {
54
- return updateAnnotation(this, annotation, subCategory);
47
+ setAnnotation(annotation) {
48
+ this.jsonProperties.annotation = annotation.toJSON();
55
49
  }
56
50
  }
57
51
  /** An element that displays textual content within a 3d model.
58
52
  * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.
59
53
  * @see [[setAnnotation]] to change the textual content.
60
- * @public
54
+ * @public @preview
61
55
  */
62
56
  export class TextAnnotation3d extends GraphicalElement3d {
63
57
  /** @internal */
@@ -67,7 +61,9 @@ export class TextAnnotation3d extends GraphicalElement3d {
67
61
  return new TextAnnotation3d(props, iModel);
68
62
  }
69
63
  toJSON() {
70
- return super.toJSON();
64
+ const props = super.toJSON();
65
+ props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.placement, this.jsonProperties.annotation, this.category);
66
+ return props;
71
67
  }
72
68
  /** Extract the textual content, if present.
73
69
  * @see [[setAnnotation]] to change it.
@@ -79,11 +75,9 @@ export class TextAnnotation3d extends GraphicalElement3d {
79
75
  /** Change the textual content, updating the element's geometry and placement accordingly.
80
76
  * @see [[getAnnotation]] to extract the current annotation.
81
77
  * @param annotation The new annotation
82
- * @param subCategory If specified, the subcategory on which to define the geometry; otherwise, the default subcategory of the element's category is used.
83
- * @returns true if the annotation was successfully updated.
84
78
  */
85
- setAnnotation(annotation, subCategory) {
86
- return updateAnnotation(this, annotation, subCategory);
79
+ setAnnotation(annotation) {
80
+ this.jsonProperties.annotation = annotation.toJSON();
87
81
  }
88
82
  }
89
83
  //# sourceMappingURL=TextAnnotationElement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextAnnotationElement.js","sourceRoot":"","sources":["../../../src/annotations/TextAnnotationElement.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAgD,cAAc,EAAqE,MAAM,oBAAoB,CAAC;AAEtL,OAAO,EAAE,mBAAmB,EAAE,kBAAkB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EAAE,CAAC;IACvD,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Elements\n */\n\nimport { ElementGeometry, ElementGeometryBuilderParams, PlacementProps, TextAnnotation, TextAnnotation2dProps, TextAnnotation3dProps, TextAnnotationProps } from \"@itwin/core-common\";\nimport { IModelDb } from \"../IModelDb\";\nimport { AnnotationElement2d, GraphicalElement3d } from \"../Element\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { layoutTextBlock } from \"./TextBlockLayout\";\nimport { appendTextAnnotationGeometry } from \"./TextAnnotationGeometry\";\n\nfunction getElementGeometryBuilderParams(iModel: IModelDb, _placementProps: PlacementProps, annotationProps: TextAnnotationProps, categoryId: Id64String, _subCategory?: Id64String): ElementGeometryBuilderParams {\n const textBlock = TextAnnotation.fromJSON(annotationProps).textBlock;\n const layout = layoutTextBlock({ iModel, textBlock });\n const builder = new ElementGeometry.Builder();\n appendTextAnnotationGeometry({ layout, annotationProps, builder, categoryId })\n\n return { entryArray: builder.entries };\n}\n\n/** An element that displays textual content within a 2d model.\n * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.\n * @see [[setAnnotation]] to change the textual content.\n * @public @preview\n */\nexport class TextAnnotation2d extends AnnotationElement2d {\n /** @internal */\n public static override get className(): string { return \"TextAnnotation2d\"; }\n protected constructor(props: TextAnnotation2dProps, iModel: IModelDb) { super(props, iModel); }\n\n public static fromJSON(props: TextAnnotation2dProps, iModel: IModelDb): TextAnnotation2d {\n return new TextAnnotation2d(props, iModel);\n }\n\n public override toJSON(): TextAnnotation2dProps {\n const props = super.toJSON();\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.placement, this.jsonProperties.annotation, this.category);\n\n return props;\n }\n\n /** Extract the textual content, if present.\n * @see [[setAnnotation]] to change it.\n */\n public getAnnotation(): TextAnnotation | undefined {\n const json = this.jsonProperties.annotation;\n return json ? TextAnnotation.fromJSON(json) : undefined;\n }\n\n /** Change the textual content, updating the element's geometry and placement accordingly.\n * @see [[getAnnotation]] to extract the current annotation.\n * @param annotation The new annotation\n */\n public setAnnotation(annotation: TextAnnotation) {\n this.jsonProperties.annotation = annotation.toJSON();\n }\n}\n\n/** An element that displays textual content within a 3d model.\n * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.\n * @see [[setAnnotation]] to change the textual content.\n * @public @preview\n */\nexport class TextAnnotation3d extends GraphicalElement3d {\n /** @internal */\n public static override get className(): string { return \"TextAnnotation3d\"; }\n protected constructor(props: TextAnnotation3dProps, iModel: IModelDb) { super(props, iModel); }\n\n public static fromJSON(props: TextAnnotation3dProps, iModel: IModelDb): TextAnnotation3d {\n return new TextAnnotation3d(props, iModel);\n }\n\n public override toJSON(): TextAnnotation3dProps {\n const props = super.toJSON();\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.placement, this.jsonProperties.annotation, this.category);\n\n return props;\n }\n\n /** Extract the textual content, if present.\n * @see [[setAnnotation]] to change it.\n */\n public getAnnotation(): TextAnnotation | undefined {\n const json = this.jsonProperties.annotation;\n return json ? TextAnnotation.fromJSON(json) : undefined;\n }\n\n /** Change the textual content, updating the element's geometry and placement accordingly.\n * @see [[getAnnotation]] to extract the current annotation.\n * @param annotation The new annotation\n */\n public setAnnotation(annotation: TextAnnotation) {\n this.jsonProperties.annotation = annotation.toJSON();\n }\n}\n"]}
@@ -0,0 +1,31 @@
1
+ /** @packageDocumentation
2
+ * @module ElementGeometry
3
+ */
4
+ import { ElementGeometry, TextAnnotationProps } from "@itwin/core-common";
5
+ import { TextBlockLayout } from "./TextBlockLayout";
6
+ import { Id64String } from "@itwin/core-bentley";
7
+ /**
8
+ * Properties required to compute the geometry of a text annotation.
9
+ * @beta
10
+ * @see [[appendTextAnnotationGeometry]] to append the geometry to an [[ElementGeometry.Builder]].
11
+ */
12
+ export interface AppendTextAnnotationGeometryArgs {
13
+ /** The annotation to be drawn. Be sure to include a TextBlock with runs or no geometry will be produced. */
14
+ annotationProps: TextAnnotationProps;
15
+ /** Layout provided by calling [[layoutTextBlock]] */
16
+ layout: TextBlockLayout;
17
+ /** Builder that will be added to in place */
18
+ builder: ElementGeometry.Builder;
19
+ /** The category the element will belong to. This will passed into the [[GeometryParams]] */
20
+ categoryId: Id64String;
21
+ /** The optional sub-category the element will belong to. This will passed into the [[GeometryParams]] */
22
+ subCategoryId?: Id64String;
23
+ /** Whether or not to draw geometry for things like the snap points, range, and anchor point */
24
+ wantDebugGeometry?: boolean;
25
+ }
26
+ /** Constructs the TextBlockGeometry and frame geometry and appends the geometry to the provided builder.
27
+ * @returns true if the geometry was successfully appended.
28
+ * @beta
29
+ */
30
+ export declare function appendTextAnnotationGeometry(props: AppendTextAnnotationGeometryArgs): boolean;
31
+ //# sourceMappingURL=TextAnnotationGeometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextAnnotationGeometry.d.ts","sourceRoot":"","sources":["../../../src/annotations/TextAnnotationGeometry.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAY,eAAe,EAA+C,mBAAmB,EAAuB,MAAM,oBAAoB,CAAC;AACtJ,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAQ,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAIvD;;;;GAIG;AACH,MAAM,WAAW,gCAAgC;IAC/C,4GAA4G;IAC5G,eAAe,EAAE,mBAAmB,CAAC;IACrC,qDAAqD;IACrD,MAAM,EAAE,eAAe,CAAC;IACxB,6CAA6C;IAC7C,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC;IACjC,4FAA4F;IAC5F,UAAU,EAAE,UAAU,CAAA;IACtB,yGAAyG;IACzG,aAAa,CAAC,EAAE,UAAU,CAAA;IAC1B,+FAA+F;IAC/F,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,gCAAgC,GAAG,OAAO,CAuB7F"}
@@ -0,0 +1,80 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /** @packageDocumentation
6
+ * @module ElementGeometry
7
+ */
8
+ import { ColorDef, FillDisplay, GeometryParams, TextAnnotation } from "@itwin/core-common";
9
+ import { LineString3d, PointString3d, Range2d } from "@itwin/core-geometry";
10
+ import { Id64 } from "@itwin/core-bentley";
11
+ import { produceTextBlockGeometry } from "./TextBlockGeometry";
12
+ import { appendFrameToBuilder, computeIntervalPoints } from "./FrameGeometry";
13
+ /** Constructs the TextBlockGeometry and frame geometry and appends the geometry to the provided builder.
14
+ * @returns true if the geometry was successfully appended.
15
+ * @beta
16
+ */
17
+ export function appendTextAnnotationGeometry(props) {
18
+ const annotation = TextAnnotation.fromJSON(props.annotationProps);
19
+ const range = Range2d.fromJSON(props.layout.range);
20
+ const transform = annotation.computeTransform(range);
21
+ let result = true;
22
+ // Construct the TextBlockGeometry
23
+ const params = new GeometryParams(props.categoryId, props.subCategoryId);
24
+ const entries = produceTextBlockGeometry(props.layout, annotation.computeTransform(props.layout.range));
25
+ result = result && props.builder.appendTextBlock(entries, params);
26
+ // Construct the frame geometry
27
+ if (annotation.frame && annotation.frame.shape !== "none") {
28
+ result = result && appendFrameToBuilder(props.builder, annotation.frame, range, transform, params);
29
+ }
30
+ // Construct the debug geometry
31
+ if (props.wantDebugGeometry) {
32
+ result = result && debugAnchorPoint(props.builder, annotation, props.layout, annotation.computeTransform(props.layout.range));
33
+ if (annotation.frame)
34
+ result = result && debugSnapPoints(props.builder, annotation.frame, props.layout.range, annotation.computeTransform(props.layout.range));
35
+ }
36
+ return result;
37
+ }
38
+ ;
39
+ /**
40
+ * Draws the anchor point and margins of the text annotation.
41
+ * The anchor point is the point around which the text rotates and is drawn as a blue x (1m by 1m).
42
+ * The margins are drawn as a blue box.
43
+ * The text range is drawn as a red box.
44
+ */
45
+ function debugAnchorPoint(builder, annotation, layout, transform) {
46
+ const range = Range2d.fromJSON(layout.range);
47
+ const debugAnchorPt = transform.multiplyPoint3d(annotation.computeAnchorPoint(range));
48
+ // Make it blue
49
+ const blueLineParams = new GeometryParams(Id64.invalid);
50
+ blueLineParams.lineColor = ColorDef.blue;
51
+ let result = builder.appendGeometryParamsChange(blueLineParams);
52
+ // Draw a blue box to show the element's margin
53
+ const marginCorners = range.corners3d(true);
54
+ transform.multiplyPoint3dArrayInPlace(marginCorners);
55
+ result = result && builder.appendGeometryQuery(LineString3d.create(marginCorners));
56
+ // Draw a blue x to show the anchor point - Rotation occurs around this point. The x will be 1 m by 1 m.
57
+ result = result && builder.appendGeometryQuery(LineString3d.create(debugAnchorPt.plusXYZ(-1, -1), debugAnchorPt.plusXYZ(1, 1)));
58
+ result = result && builder.appendGeometryQuery(LineString3d.create(debugAnchorPt.plusXYZ(1, -1), debugAnchorPt.plusXYZ(-1, 1)));
59
+ // Draw a red box to show the text range
60
+ const redLineParams = new GeometryParams(Id64.invalid);
61
+ redLineParams.lineColor = ColorDef.red;
62
+ result = result && builder.appendGeometryParamsChange(redLineParams);
63
+ const rangeCorners = layout.textRange.corners3d(true);
64
+ transform.multiplyPoint3dArrayInPlace(rangeCorners);
65
+ result = result && builder.appendGeometryQuery(LineString3d.create(rangeCorners));
66
+ return result;
67
+ }
68
+ /** Draws the interval points defined by calling [[computeIntervalPoints]]. The points are shown as black dots 5x larger than the borderWeight */
69
+ function debugSnapPoints(builder, frame, range, transform) {
70
+ if (undefined === frame.shape || frame.shape === "none")
71
+ return false;
72
+ const points = computeIntervalPoints({ frame: frame.shape, range, transform, lineIntervalFactor: 0.5, arcIntervalFactor: 0.25 });
73
+ const params = new GeometryParams(Id64.invalid);
74
+ params.lineColor = ColorDef.black;
75
+ params.weight = (frame.borderWeight ?? 1) * 5; // We want the dots to be bigger than the frame so we can see them.
76
+ params.fillDisplay = FillDisplay.Always;
77
+ const result = builder.appendGeometryParamsChange(params) && builder.appendGeometryQuery(PointString3d.create(points));
78
+ return result;
79
+ }
80
+ //# sourceMappingURL=TextAnnotationGeometry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextAnnotationGeometry.js","sourceRoot":"","sources":["../../../src/annotations/TextAnnotationGeometry.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAmB,WAAW,EAAE,cAAc,EAAE,cAAc,EAA4C,MAAM,oBAAoB,CAAC;AAEtJ,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAa,MAAM,sBAAsB,CAAC;AACvF,OAAO,EAAE,IAAI,EAAc,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAsB9E;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAAC,KAAuC;IAClF,MAAM,UAAU,GAAG,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAClE,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACnD,MAAM,SAAS,GAAG,UAAU,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACrD,IAAI,MAAM,GAAG,IAAI,CAAC;IAElB,kCAAkC;IAClC,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IACzE,MAAM,OAAO,GAAG,wBAAwB,CAAC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C,YAAY,CAAC,CAAC;IACpD,MAAM,GAAG,MAAM,IAAI,OAAO,CAAC,mBAAmB,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IAElF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,iJAAiJ;AACjJ,SAAS,eAAe,CAAC,OAAgC,EAAE,KAA0B,EAAE,KAAc,EAAE,SAAoB;IACzH,IAAI,SAAS,KAAK,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,KAAK,MAAM;QACrD,OAAO,KAAK,CAAC;IACf,MAAM,MAAM,GAAG,qBAAqB,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,GAAG,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;IAEjI,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAChD,MAAM,CAAC,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC;IAClC,MAAM,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,YAAY,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,mEAAmE;IAClH,MAAM,CAAC,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC;IAExC,MAAM,MAAM,GAAG,OAAO,CAAC,0BAA0B,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,mBAAmB,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACvH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ElementGeometry\n */\n\nimport { ColorDef, ElementGeometry, FillDisplay, GeometryParams, TextAnnotation, TextAnnotationProps, TextFrameStyleProps } from \"@itwin/core-common\";\nimport { TextBlockLayout } from \"./TextBlockLayout\";\nimport { LineString3d, PointString3d, Range2d, Transform } from \"@itwin/core-geometry\";\nimport { Id64, Id64String } from \"@itwin/core-bentley\";\nimport { produceTextBlockGeometry } from \"./TextBlockGeometry\";\nimport { appendFrameToBuilder, computeIntervalPoints } from \"./FrameGeometry\";\n\n/**\n * Properties required to compute the geometry of a text annotation.\n * @beta\n * @see [[appendTextAnnotationGeometry]] to append the geometry to an [[ElementGeometry.Builder]].\n */\nexport interface AppendTextAnnotationGeometryArgs {\n /** The annotation to be drawn. Be sure to include a TextBlock with runs or no geometry will be produced. */\n annotationProps: TextAnnotationProps;\n /** Layout provided by calling [[layoutTextBlock]] */\n layout: TextBlockLayout;\n /** Builder that will be added to in place */\n builder: ElementGeometry.Builder;\n /** The category the element will belong to. This will passed into the [[GeometryParams]] */\n categoryId: Id64String\n /** The optional sub-category the element will belong to. This will passed into the [[GeometryParams]] */\n subCategoryId?: Id64String\n /** Whether or not to draw geometry for things like the snap points, range, and anchor point */\n wantDebugGeometry?: boolean;\n}\n\n/** Constructs the TextBlockGeometry and frame geometry and appends the geometry to the provided builder.\n * @returns true if the geometry was successfully appended.\n * @beta\n */\nexport function appendTextAnnotationGeometry(props: AppendTextAnnotationGeometryArgs): boolean {\n const annotation = TextAnnotation.fromJSON(props.annotationProps);\n const range = Range2d.fromJSON(props.layout.range);\n const transform = annotation.computeTransform(range);\n let result = true;\n\n // Construct the TextBlockGeometry\n const params = new GeometryParams(props.categoryId, props.subCategoryId);\n const entries = produceTextBlockGeometry(props.layout, annotation.computeTransform(props.layout.range));\n result = result && props.builder.appendTextBlock(entries, params);\n\n // Construct the frame geometry\n if (annotation.frame && annotation.frame.shape !== \"none\") {\n result = result && appendFrameToBuilder(props.builder, annotation.frame, range, transform, params);\n }\n\n // Construct the debug geometry\n if (props.wantDebugGeometry) {\n result = result && debugAnchorPoint(props.builder, annotation, props.layout, annotation.computeTransform(props.layout.range));\n if (annotation.frame) result = result && debugSnapPoints(props.builder, annotation.frame, props.layout.range, annotation.computeTransform(props.layout.range));\n }\n\n return result;\n};\n\n/**\n * Draws the anchor point and margins of the text annotation.\n * The anchor point is the point around which the text rotates and is drawn as a blue x (1m by 1m).\n * The margins are drawn as a blue box.\n * The text range is drawn as a red box.\n */\nfunction debugAnchorPoint(builder: ElementGeometry.Builder, annotation: TextAnnotation, layout: TextBlockLayout, transform: Transform): boolean {\n const range = Range2d.fromJSON(layout.range);\n const debugAnchorPt = transform.multiplyPoint3d(annotation.computeAnchorPoint(range));\n\n // Make it blue\n const blueLineParams = new GeometryParams(Id64.invalid);\n blueLineParams.lineColor = ColorDef.blue;\n let result = builder.appendGeometryParamsChange(blueLineParams);\n\n // Draw a blue box to show the element's margin\n const marginCorners = range.corners3d(true);\n transform.multiplyPoint3dArrayInPlace(marginCorners);\n result = result && builder.appendGeometryQuery(LineString3d.create(marginCorners));\n\n // Draw a blue x to show the anchor point - Rotation occurs around this point. The x will be 1 m by 1 m.\n result = result && builder.appendGeometryQuery(LineString3d.create(debugAnchorPt.plusXYZ(-1, -1), debugAnchorPt.plusXYZ(1, 1)));\n result = result && builder.appendGeometryQuery(LineString3d.create(debugAnchorPt.plusXYZ(1, -1), debugAnchorPt.plusXYZ(-1, 1)));\n\n // Draw a red box to show the text range\n const redLineParams = new GeometryParams(Id64.invalid);\n redLineParams.lineColor = ColorDef.red;\n result = result && builder.appendGeometryParamsChange(redLineParams);\n\n const rangeCorners = layout.textRange.corners3d(true);\n transform.multiplyPoint3dArrayInPlace(rangeCorners);\n result = result && builder.appendGeometryQuery(LineString3d.create(rangeCorners));\n\n return result;\n}\n\n/** Draws the interval points defined by calling [[computeIntervalPoints]]. The points are shown as black dots 5x larger than the borderWeight */\nfunction debugSnapPoints(builder: ElementGeometry.Builder, frame: TextFrameStyleProps, range: Range2d, transform: Transform): boolean {\n if (undefined === frame.shape || frame.shape === \"none\")\n return false;\n const points = computeIntervalPoints({ frame: frame.shape, range, transform, lineIntervalFactor: 0.5, arcIntervalFactor: 0.25 });\n\n const params = new GeometryParams(Id64.invalid);\n params.lineColor = ColorDef.black;\n params.weight = (frame.borderWeight ?? 1) * 5; // We want the dots to be bigger than the frame so we can see them.\n params.fillDisplay = FillDisplay.Always;\n\n const result = builder.appendGeometryParamsChange(params) && builder.appendGeometryQuery(PointString3d.create(points));\n return result;\n}"]}
@@ -0,0 +1,16 @@
1
+ /** @packageDocumentation
2
+ * @module ElementGeometry
3
+ */
4
+ import { TextBlockGeometryProps } from "@itwin/core-common";
5
+ import { TextBlockLayout } from "./TextBlockLayout";
6
+ import { Transform } from "@itwin/core-geometry";
7
+ /**
8
+ * Produces the geometry for a text block in a way that can be interpreted by a [[GeometryStreamBuilder]] or [[ElementBuilder.Geometry]].
9
+ * To build the geometry for a whole [[TextAnnotation]], use [[appendTextAnnotationGeometry]] instead.
10
+ * @param layout of the text block as computed by [[layoutTextBlock]].
11
+ * @param documentTransform that positions the text block in world coordinates.
12
+ * @returns TextBlockGeometryProps.
13
+ * @beta
14
+ */
15
+ export declare function produceTextBlockGeometry(layout: TextBlockLayout, documentTransform: Transform): TextBlockGeometryProps;
16
+ //# sourceMappingURL=TextBlockGeometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextBlockGeometry.d.ts","sourceRoot":"","sources":["../../../src/annotations/TextBlockGeometry.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,sBAAsB,EAA2D,MAAM,oBAAoB,CAAC;AACrH,OAAO,EAAa,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAmC,SAAS,EAAY,MAAM,sBAAsB,CAAC;AAoH5F;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,eAAe,EAAE,iBAAiB,EAAE,SAAS,GAAG,sBAAsB,CAqBtH"}