@design-core/core 0.0.1 → 0.0.3

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 (254) hide show
  1. package/.eslintrc.json +14 -7
  2. package/.github/workflows/DesignCoreQA.yml +3 -1
  3. package/README.md +11 -4
  4. package/TODO.md +19 -0
  5. package/core/core/core.js +49 -42
  6. package/core/designCore.js +61 -2
  7. package/core/dimensions/alignedDimension.js +142 -0
  8. package/core/dimensions/angularDimension.js +550 -0
  9. package/core/dimensions/baseCircularDimension.js +244 -0
  10. package/core/dimensions/baseDimension.js +558 -0
  11. package/core/dimensions/baseLinearDimension.js +371 -0
  12. package/core/dimensions/diametricDimension.js +82 -0
  13. package/core/dimensions/dimension.js +298 -0
  14. package/core/dimensions/linearDimension.js +29 -0
  15. package/core/dimensions/radialDimension.js +78 -0
  16. package/core/dimensions/rotatedDimension.js +167 -0
  17. package/core/entities/arc.js +314 -60
  18. package/core/entities/arctext.js +642 -0
  19. package/core/entities/basePolyline.js +553 -94
  20. package/core/entities/circle.js +181 -54
  21. package/core/entities/entity.js +154 -74
  22. package/core/entities/hatch.js +807 -0
  23. package/core/entities/insert.js +200 -39
  24. package/core/entities/line.js +196 -134
  25. package/core/entities/lwpolyline.js +21 -44
  26. package/core/entities/point.js +194 -29
  27. package/core/entities/polyline.js +54 -7
  28. package/core/entities/rectangle.js +43 -13
  29. package/core/entities/solid.js +43 -6
  30. package/core/entities/text.js +324 -181
  31. package/core/lib/boundingBox.js +73 -13
  32. package/core/lib/canvas.js +256 -65
  33. package/core/lib/clipboard.js +198 -0
  34. package/core/lib/colour.js +144 -0
  35. package/core/lib/colours.js +367 -301
  36. package/core/lib/commandLine.js +16 -28
  37. package/core/lib/commandManager.js +115 -58
  38. package/core/lib/constants.js +23 -0
  39. package/core/lib/dxf/dxf.js +249 -34
  40. package/core/lib/dxf/dxfFile.js +23 -38
  41. package/core/lib/dxf/dxfIterator.js +17 -5
  42. package/core/lib/dxf/dxfRead.js +23 -7
  43. package/core/lib/dxf/dxfWrite.js +39 -129
  44. package/core/lib/dxf/handleManager.js +97 -0
  45. package/core/lib/dxf/sections/blocks.js +16 -2
  46. package/core/lib/dxf/sections/entities.js +17 -3
  47. package/core/lib/dxf/sections/header.js +10 -1
  48. package/core/lib/dxf/sections/objects.js +36 -0
  49. package/core/lib/dxf/sections/section.js +43 -5
  50. package/core/lib/dxf/sections/tables.js +17 -3
  51. package/core/lib/entityManager.js +178 -0
  52. package/core/lib/fileio.js +14 -4
  53. package/core/lib/headers.js +229 -0
  54. package/core/lib/input.js +46 -0
  55. package/core/lib/inputManager.js +199 -194
  56. package/core/lib/intersect.js +341 -468
  57. package/core/lib/logging.js +25 -1
  58. package/core/lib/matrix.js +6 -8
  59. package/core/lib/mouse.js +24 -79
  60. package/core/lib/patterns.js +690 -0
  61. package/core/lib/promptOptions.js +133 -0
  62. package/core/lib/scene.js +71 -174
  63. package/core/lib/selectionManager.js +74 -48
  64. package/core/lib/selectionWindow.js +24 -10
  65. package/core/lib/settings.js +18 -11
  66. package/core/lib/snapping.js +129 -21
  67. package/core/lib/stateManager.js +288 -0
  68. package/core/lib/strings.js +57 -5
  69. package/core/lib/utils.js +95 -11
  70. package/core/objects/dictionary.js +43 -0
  71. package/core/objects/dictionaryManager.js +80 -0
  72. package/core/properties/dimType.js +117 -0
  73. package/core/properties/flags.js +66 -0
  74. package/core/properties/property.js +26 -0
  75. package/core/properties/propertyManager.js +65 -19
  76. package/core/tables/appId.js +31 -0
  77. package/core/tables/appIdManager.js +44 -0
  78. package/core/tables/block.js +323 -0
  79. package/core/tables/blockManager.js +48 -0
  80. package/core/tables/blockRecord.js +29 -0
  81. package/core/tables/blockRecordManager.js +37 -0
  82. package/core/tables/dimStyle.js +627 -0
  83. package/core/tables/dimStyleManager.js +187 -0
  84. package/core/tables/endblk.js +28 -0
  85. package/core/tables/layer.js +219 -0
  86. package/core/tables/layerManager.js +47 -0
  87. package/core/tables/ltype.js +85 -0
  88. package/core/tables/ltypeManager.js +65 -0
  89. package/core/tables/style.js +145 -0
  90. package/core/tables/styleManager.js +55 -0
  91. package/core/tables/styleManagerBase.js +110 -0
  92. package/core/tables/tableManagerBase.js +354 -0
  93. package/core/tables/ucs.js +28 -0
  94. package/core/tables/ucsManager.js +44 -0
  95. package/core/tables/view.js +28 -0
  96. package/core/tables/viewManager.js +44 -0
  97. package/core/tables/vport.js +70 -0
  98. package/core/tables/vportManager.js +65 -0
  99. package/core/tools/chamfer.js +343 -0
  100. package/core/tools/chamferFilletBase.js +162 -0
  101. package/core/tools/copy.js +68 -40
  102. package/core/tools/copybase.js +65 -0
  103. package/core/tools/copyclip.js +59 -0
  104. package/core/tools/cornerEntity.js +138 -0
  105. package/core/tools/cutclip.js +72 -0
  106. package/core/tools/distance.js +37 -9
  107. package/core/tools/erase.js +43 -13
  108. package/core/tools/explode.js +117 -0
  109. package/core/tools/extend.js +71 -32
  110. package/core/tools/fillet.js +336 -0
  111. package/core/tools/identify.js +33 -6
  112. package/core/tools/matchProp.js +106 -0
  113. package/core/tools/mirror.js +141 -0
  114. package/core/tools/move.js +65 -32
  115. package/core/tools/offset.js +321 -0
  116. package/core/tools/pan.js +54 -0
  117. package/core/tools/pasteclip.js +93 -0
  118. package/core/tools/purge.js +90 -0
  119. package/core/tools/rotate.js +105 -70
  120. package/core/tools/scale.js +166 -0
  121. package/core/tools/tool.js +14 -4
  122. package/core/tools/trim.js +71 -32
  123. package/core/tools/zoom.js +152 -0
  124. package/package.json +3 -305
  125. package/test/dimensions/alignedDimension.test.js +211 -0
  126. package/test/dimensions/angularDimension.test.js +243 -0
  127. package/test/dimensions/baseDimension.test.js +239 -0
  128. package/test/dimensions/diametricDimension.test.js +203 -0
  129. package/test/dimensions/dimension.test.js +102 -0
  130. package/test/dimensions/radialDimension.test.js +203 -0
  131. package/test/dimensions/rotatedDimension.test.js +224 -0
  132. package/test/entities/arc.test.js +463 -41
  133. package/test/entities/arctext.test.js +329 -0
  134. package/test/entities/basePolyline.test.js +459 -10
  135. package/test/entities/circle.test.js +312 -7
  136. package/test/entities/entity.test.js +28 -9
  137. package/test/entities/hatch.test.js +606 -0
  138. package/test/entities/insert.test.js +90 -0
  139. package/test/entities/line.test.js +182 -6
  140. package/test/entities/point.test.js +375 -37
  141. package/test/entities/solid.test.js +156 -0
  142. package/test/entities/text.test.js +533 -7
  143. package/test/integration/exportIntegration.reference.dxf +1706 -0
  144. package/test/integration/exportIntegration.test.js +186 -0
  145. package/test/integration/importExportIntegration.test.js +126 -0
  146. package/test/integration/intersectionIntegration.test.js +880 -0
  147. package/test/integration/userInputIntegration.reference.dxf +1410 -0
  148. package/test/integration/userInputIntegration.test.js +269 -0
  149. package/test/lib/boundingBox.test.js +26 -2
  150. package/test/lib/canvas.test.js +613 -5
  151. package/test/lib/clipboard.test.js +70 -0
  152. package/test/lib/colour.test.js +114 -0
  153. package/test/lib/colours.test.js +63 -18
  154. package/test/lib/commandLine.test.js +159 -22
  155. package/test/lib/commandManager.test.js +4 -4
  156. package/test/lib/constants.test.js +9 -0
  157. package/test/lib/dxf/dxfFile.test.js +6 -2
  158. package/test/lib/dxf/dxfIterator.test.js +1 -1
  159. package/test/lib/dxf/dxfWrite.test.js +173 -0
  160. package/test/lib/dxf/handleManager.test.js +137 -0
  161. package/test/lib/dxf/sections/blocks.test.js +5 -5
  162. package/test/lib/dxf/sections/entities.test.js +4 -4
  163. package/test/lib/dxf/sections/header.test.js +18 -4
  164. package/test/lib/dxf/sections/objects.test.js +132 -0
  165. package/test/lib/dxf/sections/section.test.js +29 -29
  166. package/test/lib/dxf/sections/tables.test.js +3 -3
  167. package/test/lib/entityManager.test.js +163 -0
  168. package/test/lib/headers.test.js +233 -0
  169. package/test/lib/inputManager.test.js +1144 -5
  170. package/test/lib/intersect.test.js +454 -331
  171. package/test/lib/logging.test.js +1 -1
  172. package/test/lib/matrix.test.js +1 -1
  173. package/test/lib/mouse.test.js +327 -4
  174. package/test/lib/patterns.test.js +105 -0
  175. package/test/lib/promptOptions.test.js +179 -0
  176. package/test/lib/scene.test.js +16 -52
  177. package/test/lib/selectionManager.test.js +17 -5
  178. package/test/lib/settings.test.js +111 -5
  179. package/test/lib/snapping.test.js +142 -4
  180. package/test/lib/stateManager.test.js +155 -0
  181. package/test/lib/utils.test.js +81 -1
  182. package/test/objects/dictionary.test.js +81 -0
  183. package/test/objects/dictionaryManager.test.js +34 -0
  184. package/test/properties/dimType.test.js +62 -0
  185. package/test/properties/flags.test.js +164 -0
  186. package/test/properties/property.test.js +13 -0
  187. package/test/properties/propertyManager.test.js +10 -11
  188. package/test/tables/appId.test.js +46 -0
  189. package/test/tables/appIdManager.test.js +72 -0
  190. package/test/tables/block.test.js +157 -0
  191. package/test/tables/blockManager.test.js +52 -0
  192. package/test/tables/blockRecord.test.js +39 -0
  193. package/test/tables/blockRecordManager.test.js +60 -0
  194. package/test/tables/dimstyle.test.js +72 -0
  195. package/test/tables/endblk.test.js +30 -0
  196. package/test/tables/layer.test.js +95 -0
  197. package/test/tables/layerManager.test.js +172 -0
  198. package/test/{styles → tables}/ltype.test.js +7 -7
  199. package/test/{styles → tables}/ltypeManager.test.js +2 -2
  200. package/test/tables/style.test.js +44 -0
  201. package/test/tables/stylemanagerbase.test.js +220 -0
  202. package/test/tables/tableManagerBase.test.js +194 -0
  203. package/test/tables/ucs.test.js +37 -0
  204. package/test/tables/ucsManager.test.js +48 -0
  205. package/test/tables/view.test.js +37 -0
  206. package/test/tables/viewManager.test.js +48 -0
  207. package/test/tables/vport.test.js +117 -0
  208. package/test/tables/vportManager.test.js +54 -0
  209. package/test/test-helpers/test-helpers.js +66 -0
  210. package/test/tools/chamfer.test.js +970 -0
  211. package/test/tools/chamferFilletBase.test.js +446 -0
  212. package/test/tools/copy.test.js +22 -14
  213. package/test/tools/copybase.test.js +93 -0
  214. package/test/tools/copyclip.test.js +92 -0
  215. package/test/tools/cornerEntity.test.js +201 -0
  216. package/test/tools/cutclip.test.js +94 -0
  217. package/test/tools/distance.test.js +140 -18
  218. package/test/tools/erase.test.js +12 -12
  219. package/test/tools/explode.test.js +45 -0
  220. package/test/tools/extend.test.js +326 -44
  221. package/test/tools/fillet.test.js +831 -0
  222. package/test/tools/identify.test.js +115 -16
  223. package/test/tools/matchProp.test.js +84 -0
  224. package/test/tools/mirror.test.js +475 -0
  225. package/test/tools/move.test.js +75 -19
  226. package/test/tools/offset.test.js +748 -0
  227. package/test/tools/pan.test.js +72 -0
  228. package/test/tools/pasteclip.test.js +100 -0
  229. package/test/tools/purge.test.js +89 -0
  230. package/test/tools/rotate.test.js +89 -23
  231. package/test/tools/scale.test.js +529 -0
  232. package/test/tools/trim.test.js +419 -84
  233. package/test/tools/zoom.test.js +504 -0
  234. package/core/entities/alignedDimension.js +0 -279
  235. package/core/entities/angularDimension.js +0 -194
  236. package/core/entities/baseDimension.js +0 -227
  237. package/core/entities/block.js +0 -247
  238. package/core/entities/diametricDimension.js +0 -133
  239. package/core/entities/dimension.js +0 -202
  240. package/core/entities/radialDimension.js +0 -126
  241. package/core/styles/dimStyle.js +0 -719
  242. package/core/styles/dimStyleManager.js +0 -47
  243. package/core/styles/layer.js +0 -133
  244. package/core/styles/layerManager.js +0 -40
  245. package/core/styles/ltype.js +0 -86
  246. package/core/styles/ltypeManager.js +0 -50
  247. package/core/styles/style.js +0 -158
  248. package/core/styles/styleManager.js +0 -43
  249. package/core/styles/styleManagerBase.js +0 -299
  250. package/test/entities/block.test.js +0 -22
  251. package/test/styles/dimstyle.test.js +0 -19
  252. package/test/styles/layerManager.test.js +0 -150
  253. package/test/styles/style.test.js +0 -33
  254. package/test/styles/stylemanagerbase.test.js +0 -219
@@ -0,0 +1,269 @@
1
+ import { Core } from '../../core/core/core.js';
2
+ import { DesignCore } from '../../core/designCore.js';
3
+ import { Point } from '../../core/entities/point.js';
4
+ import { Line } from '../../core/entities/line.js';
5
+ import { Circle } from '../../core/entities/circle.js';
6
+ import { Arc } from '../../core/entities/arc.js';
7
+ import { Text } from '../../core/entities/text.js';
8
+ import { Polyline } from '../../core/entities/polyline.js';
9
+ import { Hatch } from '../../core/entities/hatch.js';
10
+ import { Rectangle } from '../../core/entities/rectangle.js';
11
+ import { Copy } from '../../core/tools/copy.js';
12
+ import { Move } from '../../core/tools/move.js';
13
+ import { Rotate } from '../../core/tools/rotate.js';
14
+ import { Erase } from '../../core/tools/erase.js';
15
+ import { MatchProp } from '../../core/tools/matchProp.js';
16
+ import { Trim } from '../../core/tools/trim.js';
17
+ import { Extend } from '../../core/tools/extend.js';
18
+ import { SingleSelection } from '../../core/lib/selectionManager.js';
19
+
20
+ import { readFileSync } from 'fs';
21
+ import { fileURLToPath } from 'url';
22
+ import { dirname, join } from 'path';
23
+
24
+ const __filename = fileURLToPath(import.meta.url);
25
+ const __dirname = dirname(__filename);
26
+
27
+ let core;
28
+
29
+ /**
30
+ * Create a mock for inputManager.requestInput that feeds
31
+ * sequential inputs and rejects when exhausted (simulating Escape)
32
+ * @param {Array} inputs - array of input values to return in order
33
+ * @return {Function} mock requestInput function
34
+ */
35
+ function mockRequestInput(inputs) {
36
+ let callCount = 0;
37
+ return async () => {
38
+ if (callCount < inputs.length) {
39
+ return inputs[callCount++];
40
+ }
41
+ throw new Error('cancelled');
42
+ };
43
+ }
44
+
45
+ /**
46
+ * Execute an entity command with mocked user inputs
47
+ * @param {Object} command - the command instance to execute
48
+ * @param {Array} inputs - array of input values to feed sequentially
49
+ */
50
+ async function executeWithInputs(command, inputs) {
51
+ const origRequestInput = DesignCore.Scene.inputManager.requestInput.bind(DesignCore.Scene.inputManager);
52
+ DesignCore.Scene.inputManager.requestInput = mockRequestInput(inputs);
53
+ await command.execute();
54
+ DesignCore.Scene.inputManager.requestInput = origRequestInput;
55
+ }
56
+
57
+ /**
58
+ * Execute a tool command with mocked user inputs and pre-populated selection
59
+ * @param {Object} tool - the tool instance to execute
60
+ * @param {Array} selectionIndices - entity indices to pre-select
61
+ * @param {Array} inputs - array of input values to feed sequentially
62
+ */
63
+ async function executeToolWithInputs(tool, selectionIndices, inputs) {
64
+ DesignCore.Scene.selectionManager.reset();
65
+ for (const idx of selectionIndices) {
66
+ DesignCore.Scene.selectionManager.addToSelectionSet(idx);
67
+ }
68
+
69
+ // Set active command so actionCommand recognises Tool instances
70
+ DesignCore.Scene.inputManager.activeCommand = tool;
71
+
72
+ const origRequestInput = DesignCore.Scene.inputManager.requestInput.bind(DesignCore.Scene.inputManager);
73
+ DesignCore.Scene.inputManager.requestInput = mockRequestInput(inputs);
74
+ await tool.execute();
75
+ DesignCore.Scene.inputManager.requestInput = origRequestInput;
76
+ }
77
+
78
+ beforeAll(async () => {
79
+ core = new Core();
80
+
81
+ // ---- Entity Creation ----
82
+
83
+ // Line: two segments from (0,0) to (100,100) to (200,0)
84
+ const line = new Line();
85
+ await executeWithInputs(line, [
86
+ new Point(0, 0),
87
+ new Point(100, 100),
88
+ new Point(200, 0),
89
+ ]);
90
+ // idx 0: Line (0,0)→(100,100)
91
+ // idx 1: Line (100,100)→(200,0)
92
+
93
+ // Circle: center (300, 300) radius 50
94
+ const circle = new Circle();
95
+ await executeWithInputs(circle, [
96
+ new Point(300, 300),
97
+ 50,
98
+ ]);
99
+ // idx 2: Circle
100
+
101
+ // Arc: center (500, 500), start point (530, 500), end angle 90 degrees
102
+ const arc = new Arc();
103
+ await executeWithInputs(arc, [
104
+ new Point(500, 500),
105
+ new Point(530, 500),
106
+ 90,
107
+ ]);
108
+ // idx 3: Arc
109
+
110
+ // Polyline: (0, 200) -> (50, 200) -> (50, 250) -> (0, 250)
111
+ const polyline = new Polyline();
112
+ await executeWithInputs(polyline, [
113
+ new Point(0, 200),
114
+ new Point(50, 200),
115
+ new Point(50, 250),
116
+ new Point(0, 250),
117
+ ]);
118
+ // idx 4: Polyline
119
+
120
+ // Text: position (10, 400), height 5, rotation 0, string "Hello"
121
+ const text = new Text();
122
+ await executeWithInputs(text, [
123
+ new Point(10, 400),
124
+ 5,
125
+ 0,
126
+ 'Hello',
127
+ ]);
128
+ // idx 5: Text
129
+
130
+ // Rectangle: corners (600, 0) and (700, 100) — creates a closed Polyline
131
+ const rectangle = new Rectangle();
132
+ await executeWithInputs(rectangle, [
133
+ new Point(600, 0),
134
+ new Point(700, 100),
135
+ ]);
136
+ // idx 6: Polyline (rectangle)
137
+
138
+ // Hatch: uses the rectangle boundary as selection
139
+ const rectangleEntity = DesignCore.Scene.entities.get(DesignCore.Scene.entities.count() - 1);
140
+ const origSelectedItems = DesignCore.Scene.selectionManager.selectedItems;
141
+ DesignCore.Scene.selectionManager.selectedItems = [rectangleEntity];
142
+
143
+ const hatch = new Hatch();
144
+ await executeWithInputs(hatch, [
145
+ 'accept',
146
+ ]);
147
+ DesignCore.Scene.selectionManager.selectedItems = origSelectedItems;
148
+ // idx 7: Hatch
149
+
150
+ // Additional lines for trim and extend geometry
151
+ // Trim: horizontal boundary and vertical target that cross
152
+ const trimBoundary = new Line();
153
+ await executeWithInputs(trimBoundary, [
154
+ new Point(800, 50),
155
+ new Point(1000, 50),
156
+ ]);
157
+ // idx 8: Line (800,50)→(1000,50) - trim boundary
158
+
159
+ const trimTarget = new Line();
160
+ await executeWithInputs(trimTarget, [
161
+ new Point(900, 0),
162
+ new Point(900, 100),
163
+ ]);
164
+ // idx 9: Line (900,0)→(900,100) - trim target (intersects at 900,50)
165
+
166
+ // Extend: boundary and short target that doesn't reach it
167
+ const extendBoundary = new Line();
168
+ await executeWithInputs(extendBoundary, [
169
+ new Point(1100, 0),
170
+ new Point(1100, 200),
171
+ ]);
172
+ // idx 10: Line (1100,0)→(1100,200) - extend boundary
173
+
174
+ const extendTarget = new Line();
175
+ await executeWithInputs(extendTarget, [
176
+ new Point(1000, 100),
177
+ new Point(1050, 100),
178
+ ]);
179
+ // idx 11: Line (1000,100)→(1050,100) - extend target
180
+
181
+ // MatchProp source line on a different layer
182
+ DesignCore.LayerManager.addItem({ name: 'TOOL_LAYER' });
183
+ DesignCore.LayerManager.setCstyle('TOOL_LAYER');
184
+
185
+ const matchSource = new Line();
186
+ await executeWithInputs(matchSource, [
187
+ new Point(800, 800),
188
+ new Point(900, 900),
189
+ ]);
190
+ // idx 12: Line on TOOL_LAYER
191
+
192
+ DesignCore.LayerManager.setCstyle('0');
193
+
194
+ // ---- Tool Operations ----
195
+ // Operations ordered so that index-shifting removals (Trim, Erase) happen last.
196
+
197
+ // Copy: copy line[0] offset by (0, -100)
198
+ await executeToolWithInputs(new Copy(), [0], [
199
+ new Point(0, 0),
200
+ new Point(0, -100),
201
+ ]);
202
+ // idx 13: copy of line[0]
203
+
204
+ // Move: move the copied line by (400, 0)
205
+ await executeToolWithInputs(new Move(), [13], [
206
+ new Point(0, 0),
207
+ new Point(400, 0),
208
+ ]);
209
+
210
+ // Rotate: rotate line[1] by 45 degrees around (100,100)
211
+ await executeToolWithInputs(new Rotate(), [1], [
212
+ new Point(100, 100),
213
+ 45,
214
+ ]);
215
+
216
+ // MatchProp: copy properties from TOOL_LAYER source (idx 12) to line[0]
217
+ // Pre-select 1 item → used as source
218
+ await executeToolWithInputs(new MatchProp(), [12], [
219
+ { selectionSet: [0] },
220
+ ]);
221
+ // idx 0: layer changed to TOOL_LAYER
222
+
223
+ // Extend: extend short line (idx 11) to boundary (idx 10)
224
+ // Mouse near right end → extends from right end
225
+ const origPointOnScene = DesignCore.Mouse.pointOnScene.bind(DesignCore.Mouse);
226
+ DesignCore.Mouse.pointOnScene = () => new Point(1050, 100);
227
+
228
+ await executeToolWithInputs(new Extend(), [10], [
229
+ new SingleSelection(11, new Point(1050, 100)),
230
+ ]);
231
+
232
+ // Trim: trim vertical line (idx 9) using horizontal line (idx 8) as boundary
233
+ // Mouse below intersection → removes bottom segment
234
+ DesignCore.Mouse.pointOnScene = () => new Point(900, 25);
235
+
236
+ await executeToolWithInputs(new Trim(), [8], [
237
+ new SingleSelection(9, new Point(900, 25)),
238
+ ]);
239
+ // idx 9 removed, trimmed line added at end
240
+ // indices 10+ shift down by 1: matchprop source (was 12) → now 11
241
+
242
+ DesignCore.Mouse.pointOnScene = origPointOnScene;
243
+
244
+ // Erase: remove the matchprop source line (now idx 11 after trim shift)
245
+ await executeToolWithInputs(new Erase(), [11], []);
246
+ // matchprop source line removed
247
+ });
248
+
249
+ let dxfOutput;
250
+
251
+ beforeAll(() => {
252
+ dxfOutput = core.saveFile('R2018');
253
+ });
254
+
255
+ test('Test DXF output contains all entity types', () => {
256
+ expect(dxfOutput).toContain('LINE');
257
+ expect(dxfOutput).toContain('CIRCLE');
258
+ expect(dxfOutput).toContain('ARC');
259
+ expect(dxfOutput).toContain('POLYLINE');
260
+ expect(dxfOutput).toContain('TEXT');
261
+ expect(dxfOutput).toContain('HATCH');
262
+ });
263
+
264
+ test('Test DXF output matches reference file', () => {
265
+ const referencePath = join(__dirname, 'userInputIntegration.reference.dxf');
266
+ const reference = readFileSync(referencePath, 'utf8');
267
+
268
+ expect(dxfOutput).toBe(reference);
269
+ });
@@ -1,5 +1,5 @@
1
- import {Point} from '../../core/entities/point';
2
- import {BoundingBox} from '../../core/lib/boundingBox';
1
+ import { Point } from '../../core/entities/point';
2
+ import { BoundingBox } from '../../core/lib/boundingBox';
3
3
 
4
4
  const firstCorner = new Point(101, 102);
5
5
  const secondCorner = new Point(201, 202);
@@ -29,6 +29,30 @@ test('Test BoundingBox.yLength', () => {
29
29
  expect(bb.yLength).toBe(100);
30
30
  });
31
31
 
32
+ test('Test BoundingBox.centerPoint', () => {
33
+ expect(bb.centerPoint.x).toBe(151);
34
+ expect(bb.centerPoint.y).toBe(152);
35
+ });
36
+
37
+ test('Test BoundingBox.isInside', () => {
38
+ const outsidePoint = new Point();
39
+ expect(bb.isInside(outsidePoint)).toBe(false);
40
+
41
+ const outsidePointLessX = new Point(100, 152);
42
+ expect(bb.isInside(outsidePointLessX)).toBe(false);
43
+
44
+ const outsidePointMoreX = new Point(101, 152);
45
+ expect(bb.isInside(outsidePointMoreX)).toBe(true);
46
+
47
+ const outsidePointLessY = new Point(151, 101);
48
+ expect(bb.isInside(outsidePointLessY)).toBe(false);
49
+
50
+ const outsidePointMoreY = new Point(151, 203);
51
+ expect(bb.isInside(outsidePointMoreY)).toBe(false);
52
+
53
+ const insidePoint = new Point(151, 152);
54
+ expect(bb.isInside(insidePoint)).toBe(true);
55
+ });
32
56
 
33
57
  test('Test BoundingBox.arcBoundingBox', () => {
34
58
  // circle