@linkiez/dxf-renew 7.1.0 → 7.2.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 (398) hide show
  1. package/.eslintrc.json +1 -16
  2. package/.yarn/install-state.gz +0 -0
  3. package/ARCHITECTURE.md +163 -0
  4. package/CHANGELOG.md +34 -0
  5. package/README.md +72 -10
  6. package/{PLAN.md → ROADMAP.md} +227 -35
  7. package/build.mjs +28 -0
  8. package/dist/dxf.js +1090 -344
  9. package/docs/FIXTURE_VALIDATION_EZDXF.md +1 -1
  10. package/lib/Helper.cjs +4 -0
  11. package/lib/Helper.cjs.map +3 -3
  12. package/lib/Helper.d.ts +19 -0
  13. package/lib/Helper.d.ts.map +1 -0
  14. package/lib/Helper.js +4 -0
  15. package/lib/Helper.js.map +2 -2
  16. package/lib/applyTransforms.d.ts +12 -0
  17. package/lib/applyTransforms.d.ts.map +1 -0
  18. package/lib/cli.cjs +1 -2
  19. package/lib/cli.cjs.map +1 -1
  20. package/lib/cli.d.ts +3 -0
  21. package/lib/cli.d.ts.map +1 -0
  22. package/lib/config.d.ts +4 -0
  23. package/lib/config.d.ts.map +1 -0
  24. package/lib/constants.d.ts +3 -0
  25. package/lib/constants.d.ts.map +1 -0
  26. package/lib/denormalise.d.ts +3 -0
  27. package/lib/denormalise.d.ts.map +1 -0
  28. package/lib/dimensionToSVG.d.ts +18 -0
  29. package/lib/dimensionToSVG.d.ts.map +1 -0
  30. package/lib/entityToPolyline.cjs +95 -0
  31. package/lib/entityToPolyline.cjs.map +3 -3
  32. package/lib/entityToPolyline.d.ts +48 -0
  33. package/lib/entityToPolyline.d.ts.map +1 -0
  34. package/lib/entityToPolyline.js +95 -0
  35. package/lib/entityToPolyline.js.map +2 -2
  36. package/lib/getRGBForEntity.d.ts +5 -0
  37. package/lib/getRGBForEntity.d.ts.map +1 -0
  38. package/lib/groupEntitiesByLayer.d.ts +3 -0
  39. package/lib/groupEntitiesByLayer.d.ts.map +1 -0
  40. package/lib/handlers/blocks.d.ts +3 -0
  41. package/lib/handlers/blocks.d.ts.map +1 -0
  42. package/lib/handlers/entities.cjs +22 -2
  43. package/lib/handlers/entities.cjs.map +3 -3
  44. package/lib/handlers/entities.d.ts +4 -0
  45. package/lib/handlers/entities.d.ts.map +1 -0
  46. package/lib/handlers/entities.js +22 -2
  47. package/lib/handlers/entities.js.map +2 -2
  48. package/lib/handlers/entity/arc.d.ts +20 -0
  49. package/lib/handlers/entity/arc.d.ts.map +1 -0
  50. package/lib/handlers/entity/attdef.d.ts +11 -0
  51. package/lib/handlers/entity/attdef.d.ts.map +1 -0
  52. package/lib/handlers/entity/attrib.d.ts +9 -0
  53. package/lib/handlers/entity/attrib.d.ts.map +1 -0
  54. package/lib/handlers/entity/circle.d.ts +17 -0
  55. package/lib/handlers/entity/circle.d.ts.map +1 -0
  56. package/lib/handlers/entity/common.d.ts +3 -0
  57. package/lib/handlers/entity/common.d.ts.map +1 -0
  58. package/lib/handlers/entity/dgnUnderlay.d.ts +33 -0
  59. package/lib/handlers/entity/dgnUnderlay.d.ts.map +1 -0
  60. package/lib/handlers/entity/dimension.d.ts +35 -0
  61. package/lib/handlers/entity/dimension.d.ts.map +1 -0
  62. package/lib/handlers/entity/dwfUnderlay.d.ts +33 -0
  63. package/lib/handlers/entity/dwfUnderlay.d.ts.map +1 -0
  64. package/lib/handlers/entity/ellipse.d.ts +10 -0
  65. package/lib/handlers/entity/ellipse.d.ts.map +1 -0
  66. package/lib/handlers/entity/hatch.d.ts +9 -0
  67. package/lib/handlers/entity/hatch.d.ts.map +1 -0
  68. package/lib/handlers/entity/image.d.ts +26 -0
  69. package/lib/handlers/entity/image.d.ts.map +1 -0
  70. package/lib/handlers/entity/insert.d.ts +10 -0
  71. package/lib/handlers/entity/insert.d.ts.map +1 -0
  72. package/lib/handlers/entity/leader.d.ts +48 -0
  73. package/lib/handlers/entity/leader.d.ts.map +1 -0
  74. package/lib/handlers/entity/line.d.ts +16 -0
  75. package/lib/handlers/entity/line.d.ts.map +1 -0
  76. package/lib/handlers/entity/lwpolyline.d.ts +10 -0
  77. package/lib/handlers/entity/lwpolyline.d.ts.map +1 -0
  78. package/lib/handlers/entity/mleader.cjs +69 -0
  79. package/lib/handlers/entity/mleader.cjs.map +7 -0
  80. package/lib/handlers/entity/mleader.d.ts +15 -0
  81. package/lib/handlers/entity/mleader.d.ts.map +1 -0
  82. package/lib/handlers/entity/mleader.js +34 -0
  83. package/lib/handlers/entity/mleader.js.map +7 -0
  84. package/lib/handlers/entity/mline.cjs +91 -0
  85. package/lib/handlers/entity/mline.cjs.map +7 -0
  86. package/lib/handlers/entity/mline.d.ts +17 -0
  87. package/lib/handlers/entity/mline.d.ts.map +1 -0
  88. package/lib/handlers/entity/mline.js +56 -0
  89. package/lib/handlers/entity/mline.js.map +7 -0
  90. package/lib/handlers/entity/mtext.d.ts +62 -0
  91. package/lib/handlers/entity/mtext.d.ts.map +1 -0
  92. package/lib/handlers/entity/ole2Frame.d.ts +9 -0
  93. package/lib/handlers/entity/ole2Frame.d.ts.map +1 -0
  94. package/lib/handlers/entity/oleframe.cjs +98 -0
  95. package/lib/handlers/entity/oleframe.cjs.map +7 -0
  96. package/lib/handlers/entity/oleframe.d.ts +9 -0
  97. package/lib/handlers/entity/oleframe.d.ts.map +1 -0
  98. package/lib/handlers/entity/oleframe.js +63 -0
  99. package/lib/handlers/entity/oleframe.js.map +7 -0
  100. package/lib/handlers/entity/pdfUnderlay.d.ts +33 -0
  101. package/lib/handlers/entity/pdfUnderlay.d.ts.map +1 -0
  102. package/lib/handlers/entity/point.d.ts +17 -0
  103. package/lib/handlers/entity/point.d.ts.map +1 -0
  104. package/lib/handlers/entity/polyline.d.ts +21 -0
  105. package/lib/handlers/entity/polyline.d.ts.map +1 -0
  106. package/lib/handlers/entity/ray.cjs +81 -0
  107. package/lib/handlers/entity/ray.cjs.map +7 -0
  108. package/lib/handlers/entity/ray.d.ts +15 -0
  109. package/lib/handlers/entity/ray.d.ts.map +1 -0
  110. package/lib/handlers/entity/ray.js +46 -0
  111. package/lib/handlers/entity/ray.js.map +7 -0
  112. package/lib/handlers/entity/region.cjs +67 -0
  113. package/lib/handlers/entity/region.cjs.map +7 -0
  114. package/lib/handlers/entity/region.d.ts +14 -0
  115. package/lib/handlers/entity/region.d.ts.map +1 -0
  116. package/lib/handlers/entity/region.js +32 -0
  117. package/lib/handlers/entity/region.js.map +7 -0
  118. package/lib/handlers/entity/shape.cjs +95 -0
  119. package/lib/handlers/entity/shape.cjs.map +7 -0
  120. package/lib/handlers/entity/shape.d.ts +22 -0
  121. package/lib/handlers/entity/shape.d.ts.map +1 -0
  122. package/lib/handlers/entity/shape.js +60 -0
  123. package/lib/handlers/entity/shape.js.map +7 -0
  124. package/lib/handlers/entity/solid.d.ts +15 -0
  125. package/lib/handlers/entity/solid.d.ts.map +1 -0
  126. package/lib/handlers/entity/spline.d.ts +30 -0
  127. package/lib/handlers/entity/spline.d.ts.map +1 -0
  128. package/lib/handlers/entity/table.cjs +71 -0
  129. package/lib/handlers/entity/table.cjs.map +7 -0
  130. package/lib/handlers/entity/table.d.ts +16 -0
  131. package/lib/handlers/entity/table.d.ts.map +1 -0
  132. package/lib/handlers/entity/table.js +36 -0
  133. package/lib/handlers/entity/table.js.map +7 -0
  134. package/lib/handlers/entity/text.d.ts +31 -0
  135. package/lib/handlers/entity/text.d.ts.map +1 -0
  136. package/lib/handlers/entity/threeDFace.d.ts +14 -0
  137. package/lib/handlers/entity/threeDFace.d.ts.map +1 -0
  138. package/lib/handlers/entity/tolerance.d.ts +25 -0
  139. package/lib/handlers/entity/tolerance.d.ts.map +1 -0
  140. package/lib/handlers/entity/trace.cjs +101 -0
  141. package/lib/handlers/entity/trace.cjs.map +7 -0
  142. package/lib/handlers/entity/trace.d.ts +15 -0
  143. package/lib/handlers/entity/trace.d.ts.map +1 -0
  144. package/lib/handlers/entity/trace.js +66 -0
  145. package/lib/handlers/entity/trace.js.map +7 -0
  146. package/lib/handlers/entity/vertex.d.ts +10 -0
  147. package/lib/handlers/entity/vertex.d.ts.map +1 -0
  148. package/lib/handlers/entity/viewport.d.ts +9 -0
  149. package/lib/handlers/entity/viewport.d.ts.map +1 -0
  150. package/lib/handlers/entity/wipeout.cjs +122 -0
  151. package/lib/handlers/entity/wipeout.cjs.map +7 -0
  152. package/lib/handlers/entity/wipeout.d.ts +28 -0
  153. package/lib/handlers/entity/wipeout.d.ts.map +1 -0
  154. package/lib/handlers/entity/wipeout.js +87 -0
  155. package/lib/handlers/entity/wipeout.js.map +7 -0
  156. package/lib/handlers/entity/xline.cjs +81 -0
  157. package/lib/handlers/entity/xline.cjs.map +7 -0
  158. package/lib/handlers/entity/xline.d.ts +15 -0
  159. package/lib/handlers/entity/xline.d.ts.map +1 -0
  160. package/lib/handlers/entity/xline.js +46 -0
  161. package/lib/handlers/entity/xline.js.map +7 -0
  162. package/lib/handlers/header.d.ts +3 -0
  163. package/lib/handlers/header.d.ts.map +1 -0
  164. package/lib/handlers/objects.cjs +43 -1
  165. package/lib/handlers/objects.cjs.map +2 -2
  166. package/lib/handlers/objects.d.ts +3 -0
  167. package/lib/handlers/objects.d.ts.map +1 -0
  168. package/lib/handlers/objects.js +43 -1
  169. package/lib/handlers/objects.js.map +2 -2
  170. package/lib/handlers/tables.cjs +96 -17
  171. package/lib/handlers/tables.cjs.map +2 -2
  172. package/lib/handlers/tables.d.ts +13 -0
  173. package/lib/handlers/tables.d.ts.map +1 -0
  174. package/lib/handlers/tables.js +96 -17
  175. package/lib/handlers/tables.js.map +2 -2
  176. package/lib/index.cjs +5 -2
  177. package/lib/index.cjs.map +3 -3
  178. package/lib/index.d.ts +10 -0
  179. package/lib/index.d.ts.map +1 -0
  180. package/lib/index.js +18 -16
  181. package/lib/index.js.map +3 -3
  182. package/lib/parseString.d.ts +3 -0
  183. package/lib/parseString.d.ts.map +1 -0
  184. package/lib/toJson.cjs +29 -0
  185. package/lib/toJson.cjs.map +7 -0
  186. package/lib/toJson.d.ts +3 -0
  187. package/lib/toJson.d.ts.map +1 -0
  188. package/lib/toJson.js +9 -0
  189. package/lib/toJson.js.map +7 -0
  190. package/lib/toPolylines.d.ts +4 -0
  191. package/lib/toPolylines.d.ts.map +1 -0
  192. package/lib/toSVG.cjs +34 -3
  193. package/lib/toSVG.cjs.map +2 -2
  194. package/lib/toSVG.d.ts +7 -0
  195. package/lib/toSVG.d.ts.map +1 -0
  196. package/lib/toSVG.js +34 -3
  197. package/lib/toSVG.js.map +2 -2
  198. package/lib/types/arc-entity.d.ts +8 -0
  199. package/lib/types/arc-entity.d.ts.map +1 -0
  200. package/lib/types/base-entity.d.ts +22 -0
  201. package/lib/types/base-entity.d.ts.map +1 -0
  202. package/lib/types/circle-entity.d.ts +6 -0
  203. package/lib/types/circle-entity.d.ts.map +1 -0
  204. package/lib/types/common.d.ts +30 -0
  205. package/lib/types/common.d.ts.map +1 -0
  206. package/lib/types/dimension-entity.d.ts +31 -0
  207. package/lib/types/dimension-entity.d.ts.map +1 -0
  208. package/lib/types/dxf.d.ts +55 -0
  209. package/lib/types/dxf.d.ts.map +1 -0
  210. package/lib/types/ellipse-entity.d.ts +11 -0
  211. package/lib/types/ellipse-entity.d.ts.map +1 -0
  212. package/lib/types/entity.cjs.map +1 -1
  213. package/lib/types/entity.d.ts +30 -0
  214. package/lib/types/entity.d.ts.map +1 -0
  215. package/lib/types/handler-internal.d.ts +44 -0
  216. package/lib/types/handler-internal.d.ts.map +1 -0
  217. package/lib/types/handler.d.ts +8 -0
  218. package/lib/types/handler.d.ts.map +1 -0
  219. package/lib/types/hatch-entity.d.ts +116 -0
  220. package/lib/types/hatch-entity.d.ts.map +1 -0
  221. package/lib/types/helper.cjs.map +1 -1
  222. package/lib/types/helper.d.ts +11 -0
  223. package/lib/types/helper.d.ts.map +1 -0
  224. package/lib/types/image-entity.d.ts +25 -0
  225. package/lib/types/image-entity.d.ts.map +1 -0
  226. package/lib/types/index.cjs +20 -0
  227. package/lib/types/index.cjs.map +2 -2
  228. package/lib/types/index.d.ts +43 -0
  229. package/lib/types/index.d.ts.map +1 -0
  230. package/lib/types/index.js +10 -0
  231. package/lib/types/index.js.map +2 -2
  232. package/lib/types/insert-entity.d.ts +16 -0
  233. package/lib/types/insert-entity.d.ts.map +1 -0
  234. package/lib/types/layer-groups.d.ts +6 -0
  235. package/lib/types/layer-groups.d.ts.map +1 -0
  236. package/lib/types/leader-entity.d.ts +28 -0
  237. package/lib/types/leader-entity.d.ts.map +1 -0
  238. package/lib/types/line-entity.d.ts +8 -0
  239. package/lib/types/line-entity.d.ts.map +1 -0
  240. package/lib/types/mleader-entity.cjs +17 -0
  241. package/lib/types/mleader-entity.cjs.map +7 -0
  242. package/lib/types/mleader-entity.d.ts +7 -0
  243. package/lib/types/mleader-entity.d.ts.map +1 -0
  244. package/lib/types/mleader-entity.js +1 -0
  245. package/lib/types/mleader-entity.js.map +7 -0
  246. package/lib/types/mline-entity.cjs +17 -0
  247. package/lib/types/mline-entity.cjs.map +7 -0
  248. package/lib/types/mline-entity.d.ts +10 -0
  249. package/lib/types/mline-entity.d.ts.map +1 -0
  250. package/lib/types/mline-entity.js +1 -0
  251. package/lib/types/mline-entity.js.map +7 -0
  252. package/lib/types/mtext-entity.d.ts +33 -0
  253. package/lib/types/mtext-entity.d.ts.map +1 -0
  254. package/lib/types/ole2frame-entity.d.ts +33 -0
  255. package/lib/types/ole2frame-entity.d.ts.map +1 -0
  256. package/lib/types/oleframe-entity.cjs +17 -0
  257. package/lib/types/oleframe-entity.cjs.map +7 -0
  258. package/lib/types/oleframe-entity.d.ts +33 -0
  259. package/lib/types/oleframe-entity.d.ts.map +1 -0
  260. package/lib/types/oleframe-entity.js +1 -0
  261. package/lib/types/oleframe-entity.js.map +7 -0
  262. package/lib/types/options.cjs.map +1 -1
  263. package/lib/types/options.d.ts +57 -0
  264. package/lib/types/options.d.ts.map +1 -0
  265. package/lib/types/point-entity.d.ts +5 -0
  266. package/lib/types/point-entity.d.ts.map +1 -0
  267. package/lib/types/polyline-entity.d.ts +17 -0
  268. package/lib/types/polyline-entity.d.ts.map +1 -0
  269. package/lib/types/polylines.d.ts +18 -0
  270. package/lib/types/polylines.d.ts.map +1 -0
  271. package/lib/types/ray-entity.cjs +17 -0
  272. package/lib/types/ray-entity.cjs.map +7 -0
  273. package/lib/types/ray-entity.d.ts +10 -0
  274. package/lib/types/ray-entity.d.ts.map +1 -0
  275. package/lib/types/ray-entity.js +1 -0
  276. package/lib/types/ray-entity.js.map +7 -0
  277. package/lib/types/region-entity.cjs +17 -0
  278. package/lib/types/region-entity.cjs.map +7 -0
  279. package/lib/types/region-entity.d.ts +10 -0
  280. package/lib/types/region-entity.d.ts.map +1 -0
  281. package/lib/types/region-entity.js +1 -0
  282. package/lib/types/region-entity.js.map +7 -0
  283. package/lib/types/shape-entity.cjs +17 -0
  284. package/lib/types/shape-entity.cjs.map +7 -0
  285. package/lib/types/shape-entity.d.ts +17 -0
  286. package/lib/types/shape-entity.d.ts.map +1 -0
  287. package/lib/types/shape-entity.js +1 -0
  288. package/lib/types/shape-entity.js.map +7 -0
  289. package/lib/types/solid-entity.d.ts +7 -0
  290. package/lib/types/solid-entity.d.ts.map +1 -0
  291. package/lib/types/spline-entity.d.ts +10 -0
  292. package/lib/types/spline-entity.d.ts.map +1 -0
  293. package/lib/types/svg.d.ts +27 -0
  294. package/lib/types/svg.d.ts.map +1 -0
  295. package/lib/types/table-entity.cjs +17 -0
  296. package/lib/types/table-entity.cjs.map +7 -0
  297. package/lib/types/table-entity.d.ts +12 -0
  298. package/lib/types/table-entity.d.ts.map +1 -0
  299. package/lib/types/table-entity.js +1 -0
  300. package/lib/types/table-entity.js.map +7 -0
  301. package/lib/types/tables.cjs.map +1 -1
  302. package/lib/types/tables.d.ts +549 -0
  303. package/lib/types/tables.d.ts.map +1 -0
  304. package/lib/types/text-entity.d.ts +21 -0
  305. package/lib/types/text-entity.d.ts.map +1 -0
  306. package/lib/types/tolerance-entity.d.ts +14 -0
  307. package/lib/types/tolerance-entity.d.ts.map +1 -0
  308. package/lib/types/trace-entity.cjs +17 -0
  309. package/lib/types/trace-entity.cjs.map +7 -0
  310. package/lib/types/trace-entity.d.ts +10 -0
  311. package/lib/types/trace-entity.d.ts.map +1 -0
  312. package/lib/types/trace-entity.js +1 -0
  313. package/lib/types/trace-entity.js.map +7 -0
  314. package/lib/types/underlay-entity.d.ts +26 -0
  315. package/lib/types/underlay-entity.d.ts.map +1 -0
  316. package/lib/types/util-types.d.ts +22 -0
  317. package/lib/types/util-types.d.ts.map +1 -0
  318. package/lib/types/viewport-entity.d.ts +79 -0
  319. package/lib/types/viewport-entity.d.ts.map +1 -0
  320. package/lib/types/wipeout-entity.cjs +17 -0
  321. package/lib/types/wipeout-entity.cjs.map +7 -0
  322. package/lib/types/wipeout-entity.d.ts +18 -0
  323. package/lib/types/wipeout-entity.d.ts.map +1 -0
  324. package/lib/types/wipeout-entity.js +1 -0
  325. package/lib/types/wipeout-entity.js.map +7 -0
  326. package/lib/types/xline-entity.cjs +17 -0
  327. package/lib/types/xline-entity.cjs.map +7 -0
  328. package/lib/types/xline-entity.d.ts +10 -0
  329. package/lib/types/xline-entity.d.ts.map +1 -0
  330. package/lib/types/xline-entity.js +1 -0
  331. package/lib/types/xline-entity.js.map +7 -0
  332. package/lib/types.d.ts +2 -0
  333. package/lib/types.d.ts.map +1 -0
  334. package/lib/util/bSpline.d.ts +8 -0
  335. package/lib/util/bSpline.d.ts.map +1 -0
  336. package/lib/util/colors.d.ts +5 -0
  337. package/lib/util/colors.d.ts.map +1 -0
  338. package/lib/util/createArcForLWPolyline.d.ts +9 -0
  339. package/lib/util/createArcForLWPolyline.d.ts.map +1 -0
  340. package/lib/util/dxfColorToRGB.d.ts +22 -0
  341. package/lib/util/dxfColorToRGB.d.ts.map +1 -0
  342. package/lib/util/escapeXmlText.d.ts +2 -0
  343. package/lib/util/escapeXmlText.d.ts.map +1 -0
  344. package/lib/util/insertKnot.d.ts +9 -0
  345. package/lib/util/insertKnot.d.ts.map +1 -0
  346. package/lib/util/logger.d.ts +10 -0
  347. package/lib/util/logger.d.ts.map +1 -0
  348. package/lib/util/rgbToColorAttribute.d.ts +7 -0
  349. package/lib/util/rgbToColorAttribute.d.ts.map +1 -0
  350. package/lib/util/rotate.d.ts +9 -0
  351. package/lib/util/rotate.d.ts.map +1 -0
  352. package/lib/util/round10.d.ts +2 -0
  353. package/lib/util/round10.d.ts.map +1 -0
  354. package/lib/util/toPiecewiseBezier.d.ts +18 -0
  355. package/lib/util/toPiecewiseBezier.d.ts.map +1 -0
  356. package/lib/util/transformBoundingBoxAndElement.d.ts +9 -0
  357. package/lib/util/transformBoundingBoxAndElement.d.ts.map +1 -0
  358. package/package.json +5 -19
  359. package/src/Helper.ts +6 -1
  360. package/src/entityToPolyline.ts +124 -2
  361. package/src/handlers/entities.ts +21 -1
  362. package/src/handlers/entity/mleader.ts +46 -0
  363. package/src/handlers/entity/mline.ts +74 -0
  364. package/src/handlers/entity/oleframe.ts +62 -0
  365. package/src/handlers/entity/ray.ts +52 -0
  366. package/src/handlers/entity/region.ts +42 -0
  367. package/src/handlers/entity/shape.ts +73 -0
  368. package/src/handlers/entity/table.ts +49 -0
  369. package/src/handlers/entity/trace.ts +72 -0
  370. package/src/handlers/entity/wipeout.ts +114 -0
  371. package/src/handlers/entity/xline.ts +52 -0
  372. package/src/handlers/objects.ts +64 -8
  373. package/src/handlers/tables.ts +134 -21
  374. package/src/index.ts +9 -18
  375. package/src/toJson.ts +8 -0
  376. package/src/toSVG.ts +45 -3
  377. package/src/types/entity.ts +20 -0
  378. package/src/types/helper.ts +2 -1
  379. package/src/types/index.ts +10 -0
  380. package/src/types/mleader-entity.ts +8 -0
  381. package/src/types/mline-entity.ts +12 -0
  382. package/src/types/oleframe-entity.ts +40 -0
  383. package/src/types/options.ts +7 -0
  384. package/src/types/ray-entity.ts +12 -0
  385. package/src/types/region-entity.ts +11 -0
  386. package/src/types/shape-entity.ts +19 -0
  387. package/src/types/table-entity.ts +14 -0
  388. package/src/types/tables.ts +76 -0
  389. package/src/types/trace-entity.ts +14 -0
  390. package/src/types/wipeout-entity.ts +20 -0
  391. package/src/types/xline-entity.ts +12 -0
  392. package/docs/DIMENSION_SUMMARY.md +0 -254
  393. package/docs/DXF_VERSION_SUPPORT.md +0 -45
  394. package/docs/ENTITY_SVG_ROADMAP.md +0 -96
  395. package/docs/IMPLEMENTED-2D-ENTITIES.md +0 -54
  396. package/docs/README.md +0 -22
  397. package/docs/SVG_RENDERING_INTEGRATION_TESTS.md +0 -119
  398. package/docs/TEXT-MTEXT-DIMENSION-SUPPORT.md +0 -241
@@ -59,4 +59,4 @@ When adding a new fixture:
59
59
  2. Run `yarn validate:fixtures`.
60
60
  3. Add unit tests (parsing) and integration tests (final SVG).
61
61
 
62
- See also: `docs/ENTITY_SVG_ROADMAP.md` (fixtureezdxf tests checklist)
62
+ See also: the entity workflow checklist in `ROADMAP.md` under “Documentation (Consolidated)Entity SVG Roadmap”.
package/lib/Helper.cjs CHANGED
@@ -34,6 +34,7 @@ module.exports = __toCommonJS(Helper_exports);
34
34
  var import_denormalise = __toESM(require("./denormalise"), 1);
35
35
  var import_groupEntitiesByLayer = __toESM(require("./groupEntitiesByLayer"), 1);
36
36
  var import_parseString = __toESM(require("./parseString"), 1);
37
+ var import_toJson = __toESM(require("./toJson"), 1);
37
38
  var import_toPolylines = __toESM(require("./toPolylines"), 1);
38
39
  var import_toSVG = __toESM(require("./toSVG"), 1);
39
40
  var import_logger = __toESM(require("./util/logger"), 1);
@@ -82,6 +83,9 @@ class Helper {
82
83
  toSVG(options) {
83
84
  return (0, import_toSVG.default)(this.parsed, options);
84
85
  }
86
+ toJson(options) {
87
+ return (0, import_toJson.default)(this.parsed, options);
88
+ }
85
89
  toPolylines() {
86
90
  return (0, import_toPolylines.default)(this.parsed);
87
91
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/Helper.ts"],
4
- "sourcesContent": ["import denormalise from './denormalise'\nimport groupEntitiesByLayer from './groupEntitiesByLayer'\nimport parseString from './parseString'\nimport toPolylines from './toPolylines'\nimport toSVG from './toSVG'\nimport logger from './util/logger'\n\nimport type { Entity, LayerGroups, ParsedDXF, ToSVGOptions } from './types'\n\nexport default class Helper {\n private readonly _contents: string\n private _parsed: ParsedDXF | null\n private _denormalised: Entity[] | null\n private _groups: LayerGroups | null\n\n constructor(contents: string) {\n if (typeof contents !== 'string') {\n throw new TypeError('Helper constructor expects a DXF string')\n }\n this._contents = contents\n this._parsed = null\n this._denormalised = null\n this._groups = null\n }\n\n parse(): ParsedDXF {\n this._parsed = parseString(this._contents)\n logger.info('parsed:', this.parsed)\n return this._parsed\n }\n\n get parsed(): ParsedDXF {\n if (this._parsed === null) {\n this.parse()\n }\n return this._parsed as ParsedDXF\n }\n\n denormalise(): Entity[] {\n this._denormalised = denormalise(this.parsed)\n logger.info('denormalised:', this._denormalised)\n return this._denormalised\n }\n\n get denormalised(): Entity[] {\n if (!this._denormalised) {\n this.denormalise()\n }\n return this._denormalised as Entity[]\n }\n\n group(): LayerGroups {\n this._groups = groupEntitiesByLayer(this.denormalised)\n return this._groups\n }\n\n get groups(): LayerGroups {\n if (!this._groups) {\n this.group()\n }\n return this._groups as LayerGroups\n }\n\n toSVG(options?: ToSVGOptions): string {\n return toSVG(this.parsed, options)\n }\n\n toPolylines(): ReturnType<typeof toPolylines> {\n return toPolylines(this.parsed)\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAwB;AACxB,kCAAiC;AACjC,yBAAwB;AACxB,yBAAwB;AACxB,mBAAkB;AAClB,oBAAmB;AAInB,MAAO,OAAqB;AAAA,EAM1B,YAAY,UAAkB;AAC5B,QAAI,OAAO,aAAa,UAAU;AAChC,YAAM,IAAI,UAAU,yCAAyC;AAAA,IAC/D;AACA,SAAK,YAAY;AACjB,SAAK,UAAU;AACf,SAAK,gBAAgB;AACrB,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA,QAAmB;AACjB,SAAK,cAAU,mBAAAA,SAAY,KAAK,SAAS;AACzC,kBAAAC,QAAO,KAAK,WAAW,KAAK,MAAM;AAClC,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,SAAoB;AACtB,QAAI,KAAK,YAAY,MAAM;AACzB,WAAK,MAAM;AAAA,IACb;AACA,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,cAAwB;AACtB,SAAK,oBAAgB,mBAAAC,SAAY,KAAK,MAAM;AAC5C,kBAAAD,QAAO,KAAK,iBAAiB,KAAK,aAAa;AAC/C,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,eAAyB;AAC3B,QAAI,CAAC,KAAK,eAAe;AACvB,WAAK,YAAY;AAAA,IACnB;AACA,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,QAAqB;AACnB,SAAK,cAAU,4BAAAE,SAAqB,KAAK,YAAY;AACrD,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,SAAsB;AACxB,QAAI,CAAC,KAAK,SAAS;AACjB,WAAK,MAAM;AAAA,IACb;AACA,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAM,SAAgC;AACpC,eAAO,aAAAC,SAAM,KAAK,QAAQ,OAAO;AAAA,EACnC;AAAA,EAEA,cAA8C;AAC5C,eAAO,mBAAAC,SAAY,KAAK,MAAM;AAAA,EAChC;AACF;",
6
- "names": ["parseString", "logger", "denormalise", "groupEntitiesByLayer", "toSVG", "toPolylines"]
4
+ "sourcesContent": ["import denormalise from './denormalise'\nimport groupEntitiesByLayer from './groupEntitiesByLayer'\nimport parseString from './parseString'\nimport toJson from './toJson'\nimport toPolylines from './toPolylines'\nimport toSVG from './toSVG'\nimport logger from './util/logger'\n\nimport type { Entity, LayerGroups, ParsedDXF, ToJsonOptions, ToSVGOptions } from './types'\n\nexport default class Helper {\n private readonly _contents: string\n private _parsed: ParsedDXF | null\n private _denormalised: Entity[] | null\n private _groups: LayerGroups | null\n\n constructor(contents: string) {\n if (typeof contents !== 'string') {\n throw new TypeError('Helper constructor expects a DXF string')\n }\n this._contents = contents\n this._parsed = null\n this._denormalised = null\n this._groups = null\n }\n\n parse(): ParsedDXF {\n this._parsed = parseString(this._contents)\n logger.info('parsed:', this.parsed)\n return this._parsed\n }\n\n get parsed(): ParsedDXF {\n if (this._parsed === null) {\n this.parse()\n }\n return this._parsed as ParsedDXF\n }\n\n denormalise(): Entity[] {\n this._denormalised = denormalise(this.parsed)\n logger.info('denormalised:', this._denormalised)\n return this._denormalised\n }\n\n get denormalised(): Entity[] {\n if (!this._denormalised) {\n this.denormalise()\n }\n return this._denormalised as Entity[]\n }\n\n group(): LayerGroups {\n this._groups = groupEntitiesByLayer(this.denormalised)\n return this._groups\n }\n\n get groups(): LayerGroups {\n if (!this._groups) {\n this.group()\n }\n return this._groups as LayerGroups\n }\n\n toSVG(options?: ToSVGOptions): string {\n return toSVG(this.parsed, options)\n }\n\n toJson(options?: ToJsonOptions): string {\n return toJson(this.parsed, options)\n }\n\n toPolylines(): ReturnType<typeof toPolylines> {\n return toPolylines(this.parsed)\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAwB;AACxB,kCAAiC;AACjC,yBAAwB;AACxB,oBAAmB;AACnB,yBAAwB;AACxB,mBAAkB;AAClB,oBAAmB;AAInB,MAAO,OAAqB;AAAA,EAM1B,YAAY,UAAkB;AAC5B,QAAI,OAAO,aAAa,UAAU;AAChC,YAAM,IAAI,UAAU,yCAAyC;AAAA,IAC/D;AACA,SAAK,YAAY;AACjB,SAAK,UAAU;AACf,SAAK,gBAAgB;AACrB,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA,QAAmB;AACjB,SAAK,cAAU,mBAAAA,SAAY,KAAK,SAAS;AACzC,kBAAAC,QAAO,KAAK,WAAW,KAAK,MAAM;AAClC,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,SAAoB;AACtB,QAAI,KAAK,YAAY,MAAM;AACzB,WAAK,MAAM;AAAA,IACb;AACA,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,cAAwB;AACtB,SAAK,oBAAgB,mBAAAC,SAAY,KAAK,MAAM;AAC5C,kBAAAD,QAAO,KAAK,iBAAiB,KAAK,aAAa;AAC/C,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,eAAyB;AAC3B,QAAI,CAAC,KAAK,eAAe;AACvB,WAAK,YAAY;AAAA,IACnB;AACA,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,QAAqB;AACnB,SAAK,cAAU,4BAAAE,SAAqB,KAAK,YAAY;AACrD,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,SAAsB;AACxB,QAAI,CAAC,KAAK,SAAS;AACjB,WAAK,MAAM;AAAA,IACb;AACA,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAM,SAAgC;AACpC,eAAO,aAAAC,SAAM,KAAK,QAAQ,OAAO;AAAA,EACnC;AAAA,EAEA,OAAO,SAAiC;AACtC,eAAO,cAAAC,SAAO,KAAK,QAAQ,OAAO;AAAA,EACpC;AAAA,EAEA,cAA8C;AAC5C,eAAO,mBAAAC,SAAY,KAAK,MAAM;AAAA,EAChC;AACF;",
6
+ "names": ["parseString", "logger", "denormalise", "groupEntitiesByLayer", "toSVG", "toJson", "toPolylines"]
7
7
  }
@@ -0,0 +1,19 @@
1
+ import toPolylines from './toPolylines';
2
+ import type { Entity, LayerGroups, ParsedDXF, ToJsonOptions, ToSVGOptions } from './types';
3
+ export default class Helper {
4
+ private readonly _contents;
5
+ private _parsed;
6
+ private _denormalised;
7
+ private _groups;
8
+ constructor(contents: string);
9
+ parse(): ParsedDXF;
10
+ get parsed(): ParsedDXF;
11
+ denormalise(): Entity[];
12
+ get denormalised(): Entity[];
13
+ group(): LayerGroups;
14
+ get groups(): LayerGroups;
15
+ toSVG(options?: ToSVGOptions): string;
16
+ toJson(options?: ToJsonOptions): string;
17
+ toPolylines(): ReturnType<typeof toPolylines>;
18
+ }
19
+ //# sourceMappingURL=Helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Helper.d.ts","sourceRoot":"","sources":["../src/Helper.ts"],"names":[],"mappings":"AAIA,OAAO,WAAW,MAAM,eAAe,CAAA;AAIvC,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE1F,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAQ;IAClC,OAAO,CAAC,OAAO,CAAkB;IACjC,OAAO,CAAC,aAAa,CAAiB;IACtC,OAAO,CAAC,OAAO,CAAoB;gBAEvB,QAAQ,EAAE,MAAM;IAU5B,KAAK,IAAI,SAAS;IAMlB,IAAI,MAAM,IAAI,SAAS,CAKtB;IAED,WAAW,IAAI,MAAM,EAAE;IAMvB,IAAI,YAAY,IAAI,MAAM,EAAE,CAK3B;IAED,KAAK,IAAI,WAAW;IAKpB,IAAI,MAAM,IAAI,WAAW,CAKxB;IAED,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM;IAIrC,MAAM,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM;IAIvC,WAAW,IAAI,UAAU,CAAC,OAAO,WAAW,CAAC;CAG9C"}
package/lib/Helper.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import denormalise from "./denormalise";
2
2
  import groupEntitiesByLayer from "./groupEntitiesByLayer";
3
3
  import parseString from "./parseString";
4
+ import toJson from "./toJson";
4
5
  import toPolylines from "./toPolylines";
5
6
  import toSVG from "./toSVG";
6
7
  import logger from "./util/logger";
@@ -49,6 +50,9 @@ class Helper {
49
50
  toSVG(options) {
50
51
  return toSVG(this.parsed, options);
51
52
  }
53
+ toJson(options) {
54
+ return toJson(this.parsed, options);
55
+ }
52
56
  toPolylines() {
53
57
  return toPolylines(this.parsed);
54
58
  }
package/lib/Helper.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/Helper.ts"],
4
- "sourcesContent": ["import denormalise from './denormalise'\nimport groupEntitiesByLayer from './groupEntitiesByLayer'\nimport parseString from './parseString'\nimport toPolylines from './toPolylines'\nimport toSVG from './toSVG'\nimport logger from './util/logger'\n\nimport type { Entity, LayerGroups, ParsedDXF, ToSVGOptions } from './types'\n\nexport default class Helper {\n private readonly _contents: string\n private _parsed: ParsedDXF | null\n private _denormalised: Entity[] | null\n private _groups: LayerGroups | null\n\n constructor(contents: string) {\n if (typeof contents !== 'string') {\n throw new TypeError('Helper constructor expects a DXF string')\n }\n this._contents = contents\n this._parsed = null\n this._denormalised = null\n this._groups = null\n }\n\n parse(): ParsedDXF {\n this._parsed = parseString(this._contents)\n logger.info('parsed:', this.parsed)\n return this._parsed\n }\n\n get parsed(): ParsedDXF {\n if (this._parsed === null) {\n this.parse()\n }\n return this._parsed as ParsedDXF\n }\n\n denormalise(): Entity[] {\n this._denormalised = denormalise(this.parsed)\n logger.info('denormalised:', this._denormalised)\n return this._denormalised\n }\n\n get denormalised(): Entity[] {\n if (!this._denormalised) {\n this.denormalise()\n }\n return this._denormalised as Entity[]\n }\n\n group(): LayerGroups {\n this._groups = groupEntitiesByLayer(this.denormalised)\n return this._groups\n }\n\n get groups(): LayerGroups {\n if (!this._groups) {\n this.group()\n }\n return this._groups as LayerGroups\n }\n\n toSVG(options?: ToSVGOptions): string {\n return toSVG(this.parsed, options)\n }\n\n toPolylines(): ReturnType<typeof toPolylines> {\n return toPolylines(this.parsed)\n }\n}\n"],
5
- "mappings": "AAAA,OAAO,iBAAiB;AACxB,OAAO,0BAA0B;AACjC,OAAO,iBAAiB;AACxB,OAAO,iBAAiB;AACxB,OAAO,WAAW;AAClB,OAAO,YAAY;AAInB,MAAO,OAAqB;AAAA,EAM1B,YAAY,UAAkB;AAC5B,QAAI,OAAO,aAAa,UAAU;AAChC,YAAM,IAAI,UAAU,yCAAyC;AAAA,IAC/D;AACA,SAAK,YAAY;AACjB,SAAK,UAAU;AACf,SAAK,gBAAgB;AACrB,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA,QAAmB;AACjB,SAAK,UAAU,YAAY,KAAK,SAAS;AACzC,WAAO,KAAK,WAAW,KAAK,MAAM;AAClC,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,SAAoB;AACtB,QAAI,KAAK,YAAY,MAAM;AACzB,WAAK,MAAM;AAAA,IACb;AACA,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,cAAwB;AACtB,SAAK,gBAAgB,YAAY,KAAK,MAAM;AAC5C,WAAO,KAAK,iBAAiB,KAAK,aAAa;AAC/C,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,eAAyB;AAC3B,QAAI,CAAC,KAAK,eAAe;AACvB,WAAK,YAAY;AAAA,IACnB;AACA,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,QAAqB;AACnB,SAAK,UAAU,qBAAqB,KAAK,YAAY;AACrD,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,SAAsB;AACxB,QAAI,CAAC,KAAK,SAAS;AACjB,WAAK,MAAM;AAAA,IACb;AACA,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAM,SAAgC;AACpC,WAAO,MAAM,KAAK,QAAQ,OAAO;AAAA,EACnC;AAAA,EAEA,cAA8C;AAC5C,WAAO,YAAY,KAAK,MAAM;AAAA,EAChC;AACF;",
4
+ "sourcesContent": ["import denormalise from './denormalise'\nimport groupEntitiesByLayer from './groupEntitiesByLayer'\nimport parseString from './parseString'\nimport toJson from './toJson'\nimport toPolylines from './toPolylines'\nimport toSVG from './toSVG'\nimport logger from './util/logger'\n\nimport type { Entity, LayerGroups, ParsedDXF, ToJsonOptions, ToSVGOptions } from './types'\n\nexport default class Helper {\n private readonly _contents: string\n private _parsed: ParsedDXF | null\n private _denormalised: Entity[] | null\n private _groups: LayerGroups | null\n\n constructor(contents: string) {\n if (typeof contents !== 'string') {\n throw new TypeError('Helper constructor expects a DXF string')\n }\n this._contents = contents\n this._parsed = null\n this._denormalised = null\n this._groups = null\n }\n\n parse(): ParsedDXF {\n this._parsed = parseString(this._contents)\n logger.info('parsed:', this.parsed)\n return this._parsed\n }\n\n get parsed(): ParsedDXF {\n if (this._parsed === null) {\n this.parse()\n }\n return this._parsed as ParsedDXF\n }\n\n denormalise(): Entity[] {\n this._denormalised = denormalise(this.parsed)\n logger.info('denormalised:', this._denormalised)\n return this._denormalised\n }\n\n get denormalised(): Entity[] {\n if (!this._denormalised) {\n this.denormalise()\n }\n return this._denormalised as Entity[]\n }\n\n group(): LayerGroups {\n this._groups = groupEntitiesByLayer(this.denormalised)\n return this._groups\n }\n\n get groups(): LayerGroups {\n if (!this._groups) {\n this.group()\n }\n return this._groups as LayerGroups\n }\n\n toSVG(options?: ToSVGOptions): string {\n return toSVG(this.parsed, options)\n }\n\n toJson(options?: ToJsonOptions): string {\n return toJson(this.parsed, options)\n }\n\n toPolylines(): ReturnType<typeof toPolylines> {\n return toPolylines(this.parsed)\n }\n}\n"],
5
+ "mappings": "AAAA,OAAO,iBAAiB;AACxB,OAAO,0BAA0B;AACjC,OAAO,iBAAiB;AACxB,OAAO,YAAY;AACnB,OAAO,iBAAiB;AACxB,OAAO,WAAW;AAClB,OAAO,YAAY;AAInB,MAAO,OAAqB;AAAA,EAM1B,YAAY,UAAkB;AAC5B,QAAI,OAAO,aAAa,UAAU;AAChC,YAAM,IAAI,UAAU,yCAAyC;AAAA,IAC/D;AACA,SAAK,YAAY;AACjB,SAAK,UAAU;AACf,SAAK,gBAAgB;AACrB,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA,QAAmB;AACjB,SAAK,UAAU,YAAY,KAAK,SAAS;AACzC,WAAO,KAAK,WAAW,KAAK,MAAM;AAClC,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,SAAoB;AACtB,QAAI,KAAK,YAAY,MAAM;AACzB,WAAK,MAAM;AAAA,IACb;AACA,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,cAAwB;AACtB,SAAK,gBAAgB,YAAY,KAAK,MAAM;AAC5C,WAAO,KAAK,iBAAiB,KAAK,aAAa;AAC/C,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,eAAyB;AAC3B,QAAI,CAAC,KAAK,eAAe;AACvB,WAAK,YAAY;AAAA,IACnB;AACA,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,QAAqB;AACnB,SAAK,UAAU,qBAAqB,KAAK,YAAY;AACrD,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,SAAsB;AACxB,QAAI,CAAC,KAAK,SAAS;AACjB,WAAK,MAAM;AAAA,IACb;AACA,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAM,SAAgC;AACpC,WAAO,MAAM,KAAK,QAAQ,OAAO;AAAA,EACnC;AAAA,EAEA,OAAO,SAAiC;AACtC,WAAO,OAAO,KAAK,QAAQ,OAAO;AAAA,EACpC;AAAA,EAEA,cAA8C;AAC5C,WAAO,YAAY,KAAK,MAAM;AAAA,EAChC;AACF;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Apply the transforms to the polyline.
3
+ *
4
+ * @param polyline the polyline
5
+ * @param transforms the transforms array
6
+ * @returns the transformed polyline
7
+ */
8
+ import type { PointTuple, Transform } from './types';
9
+ type Point = PointTuple;
10
+ export default function applyTransforms(polyline: Point[], transforms?: Transform[]): Point[];
11
+ export {};
12
+ //# sourceMappingURL=applyTransforms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyTransforms.d.ts","sourceRoot":"","sources":["../src/applyTransforms.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEpD,KAAK,KAAK,GAAG,UAAU,CAAA;AAEvB,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,QAAQ,EAAE,KAAK,EAAE,EACjB,UAAU,CAAC,EAAE,SAAS,EAAE,GACvB,KAAK,EAAE,CAsCT"}
package/lib/cli.cjs CHANGED
@@ -26,9 +26,8 @@ var import_commander = require("commander");
26
26
  var import_node_fs = __toESM(require("node:fs"), 1);
27
27
  var import_node_module = require("node:module");
28
28
  var import__ = require("./");
29
- const import_meta = {};
30
29
  const require2 = (0, import_node_module.createRequire)(
31
- typeof __filename === "string" ? __filename : import_meta.url
30
+ typeof __filename === "string" ? __filename : __filename
32
31
  );
33
32
  const { version } = require2("../package.json");
34
33
  const program = new import_commander.Command();
package/lib/cli.cjs.map CHANGED
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/cli.ts"],
4
4
  "sourcesContent": ["#!/usr/bin/env node\nimport { Command } from 'commander'\nimport fs from 'node:fs'\nimport { createRequire } from 'node:module'\n\nimport { denormalise, groupEntitiesByLayer, parseString, toSVG } from './'\n\nconst require = createRequire(\n typeof __filename === 'string' ? __filename : import.meta.url,\n)\nconst { version } = require('../package.json')\n\nconst program = new Command()\n\nprogram\n .version(version)\n .description('Converts a dxf file to a svg file.')\n .arguments('<dxfFile> [svgFile]')\n .option('-v --verbose', 'Verbose output')\n .action((dxfFile: string, svgFile: string | undefined, options: { verbose?: boolean }) => {\n const parsed = parseString(fs.readFileSync(dxfFile, 'utf-8'))\n\n if (options.verbose) {\n const groups = groupEntitiesByLayer(denormalise(parsed))\n console.log('[layer : number of entities]')\n for (const layer of Object.keys(groups)) {\n console.log(`${layer} : ${groups[layer].length}`)\n }\n }\n\n fs.writeFileSync(\n svgFile || `${dxfFile.split('.').slice(0, -1).join('.')}.svg`,\n toSVG(parsed),\n 'utf-8',\n )\n })\n .parse(process.argv)\n\nif (!process.argv.slice(2).length) {\n program.help()\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;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,OAAO,gBAAgB,gBAAgB,EACvC,OAAO,CAAC,SAAiB,SAA6B,YAAmC;AACxF,QAAM,aAAS,sBAAY,eAAAC,QAAG,aAAa,SAAS,OAAO,CAAC;AAE5D,MAAI,QAAQ,SAAS;AACnB,UAAM,aAAS,mCAAqB,sBAAY,MAAM,CAAC;AACvD,YAAQ,IAAI,8BAA8B;AAC1C,eAAW,SAAS,OAAO,KAAK,MAAM,GAAG;AACvC,cAAQ,IAAI,GAAG,KAAK,MAAM,OAAO,KAAK,EAAE,MAAM,EAAE;AAAA,IAClD;AAAA,EACF;AAEA,iBAAAA,QAAG;AAAA,IACD,WAAW,GAAG,QAAQ,MAAM,GAAG,EAAE,MAAM,GAAG,EAAE,EAAE,KAAK,GAAG,CAAC;AAAA,QACvD,gBAAM,MAAM;AAAA,IACZ;AAAA,EACF;AACF,CAAC,EACA,MAAM,QAAQ,IAAI;AAErB,IAAI,CAAC,QAAQ,KAAK,MAAM,CAAC,EAAE,QAAQ;AACjC,UAAQ,KAAK;AACf;",
6
6
  "names": ["require", "fs"]
7
7
  }
package/lib/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import type { Config } from './types';
2
+ declare const config: Config;
3
+ export default config;
4
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAErC,QAAA,MAAM,MAAM,EAAE,MAIb,CAAA;AAED,eAAe,MAAM,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { ZeroTransform } from './types';
2
+ export declare const ZERO_TRANSFORM: ZeroTransform;
3
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C,eAAO,MAAM,cAAc,EAAE,aAU5B,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { Entity, ParsedDXF } from './types';
2
+ export default function denormalise(parseResult: ParsedDXF): Entity[];
3
+ //# sourceMappingURL=denormalise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"denormalise.d.ts","sourceRoot":"","sources":["../src/denormalise.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAMR,MAAM,EAIN,SAAS,EAKZ,MAAM,SAAS,CAAA;AAsKhB,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,WAAW,EAAE,SAAS,GAAG,MAAM,EAAE,CAiCpE"}
@@ -0,0 +1,18 @@
1
+ import { Box2 } from 'vecks';
2
+ import type { DimensionEntity, ToSVGOptions } from './types';
3
+ import type { DimStyleTable } from './types/dxf';
4
+ import type { BoundsAndElement } from './types/svg';
5
+ export interface DimensionViewport {
6
+ width: number;
7
+ height: number;
8
+ }
9
+ export declare const getDimensionGeometryBBox: (entity: DimensionEntity) => Box2;
10
+ /**
11
+ * Render DIMENSION entity to SVG with proper DIMSTYLE support
12
+ */
13
+ export default function dimensionToSVG(entity: DimensionEntity, dimStyle?: DimStyleTable, options?: ToSVGOptions, viewport?: DimensionViewport): BoundsAndElement;
14
+ /**
15
+ * Create SVG marker definition for dimension arrows
16
+ */
17
+ export declare function createArrowMarker(id: string, size: number, color: string, direction?: 'forward' | 'backward'): string;
18
+ //# sourceMappingURL=dimensionToSVG.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dimensionToSVG.d.ts","sourceRoot":"","sources":["../src/dimensionToSVG.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAM5B,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAInD,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf;AAqCD,eAAO,MAAM,wBAAwB,GAAI,QAAQ,eAAe,KAAG,IAqBlE,CAAA;AA6ND;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,MAAM,EAAE,eAAe,EACvB,QAAQ,CAAC,EAAE,aAAa,EACxB,OAAO,CAAC,EAAE,YAAY,EACtB,QAAQ,CAAC,EAAE,iBAAiB,GAC3B,gBAAgB,CAoBlB;AA0HD;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,SAAS,GAAE,SAAS,GAAG,UAAsB,GAC5C,MAAM,CASR"}
@@ -144,12 +144,95 @@ const polyfaceOutline = (entity) => {
144
144
  function entityToPolyline(entity, options) {
145
145
  options = options || {};
146
146
  let polyline;
147
+ const INFINITE_LINE_LENGTH = 1e3;
148
+ const normalize2 = (x, y) => {
149
+ const len = Math.hypot(x, y);
150
+ if (len === 0) return null;
151
+ return { x: x / len, y: y / len };
152
+ };
147
153
  if (entity.type === "LINE") {
148
154
  polyline = [
149
155
  [entity.start.x, entity.start.y],
150
156
  [entity.end.x, entity.end.y]
151
157
  ];
152
158
  }
159
+ if (entity.type === "LEADER") {
160
+ if (entity.vertices.length >= 2) {
161
+ polyline = entity.vertices.map((v) => [v.x, v.y]);
162
+ } else {
163
+ import_logger.default.warn("LEADER entity with insufficient vertices");
164
+ polyline = [];
165
+ }
166
+ }
167
+ if (entity.type === "RAY") {
168
+ const dir = normalize2(entity.direction.x, entity.direction.y);
169
+ if (dir === null) {
170
+ import_logger.default.warn("RAY entity with zero direction vector");
171
+ polyline = [];
172
+ } else {
173
+ polyline = [
174
+ [entity.start.x, entity.start.y],
175
+ [
176
+ entity.start.x + dir.x * INFINITE_LINE_LENGTH,
177
+ entity.start.y + dir.y * INFINITE_LINE_LENGTH
178
+ ]
179
+ ];
180
+ }
181
+ }
182
+ if (entity.type === "XLINE") {
183
+ const dir = normalize2(entity.direction.x, entity.direction.y);
184
+ if (dir === null) {
185
+ import_logger.default.warn("XLINE entity with zero direction vector");
186
+ polyline = [];
187
+ } else {
188
+ polyline = [
189
+ [
190
+ entity.basePoint.x - dir.x * INFINITE_LINE_LENGTH,
191
+ entity.basePoint.y - dir.y * INFINITE_LINE_LENGTH
192
+ ],
193
+ [
194
+ entity.basePoint.x + dir.x * INFINITE_LINE_LENGTH,
195
+ entity.basePoint.y + dir.y * INFINITE_LINE_LENGTH
196
+ ]
197
+ ];
198
+ }
199
+ }
200
+ if (entity.type === "SHAPE") {
201
+ const x = entity.insertionPoint?.x ?? 0;
202
+ const y = entity.insertionPoint?.y ?? 0;
203
+ const size = entity.size ?? 0;
204
+ const scaleX = entity.relativeXScale ?? 1;
205
+ const length = size * scaleX;
206
+ polyline = [
207
+ [x, y],
208
+ [x + length, y]
209
+ ];
210
+ }
211
+ if (entity.type === "WIPEOUT") {
212
+ const verts = entity.clipBoundaryVertices;
213
+ if (!verts || verts.length < 2) {
214
+ import_logger.default.warn("WIPEOUT entity with missing clip boundary vertices");
215
+ polyline = [];
216
+ } else {
217
+ const insX = entity.insertionPoint?.x ?? 0;
218
+ const insY = entity.insertionPoint?.y ?? 0;
219
+ const ux = entity.uVector?.x ?? 1;
220
+ const uy = entity.uVector?.y ?? 0;
221
+ const vx = entity.vVector?.x ?? 0;
222
+ const vy = entity.vVector?.y ?? 1;
223
+ polyline = verts.map((p) => [
224
+ insX + ux * p.x + vx * p.y,
225
+ insY + uy * p.x + vy * p.y
226
+ ]);
227
+ if (polyline.length > 0) {
228
+ const first = polyline[0];
229
+ const last = polyline[polyline.length - 1];
230
+ if (first[0] !== last[0] || first[1] !== last[1]) {
231
+ polyline.push(first);
232
+ }
233
+ }
234
+ }
235
+ }
153
236
  if (entity.type === "LWPOLYLINE" || entity.type === "POLYLINE") {
154
237
  polyline = [];
155
238
  if (entity.polyfaceMesh) {
@@ -234,6 +317,18 @@ function entityToPolyline(entity, options) {
234
317
  entity.weights
235
318
  );
236
319
  }
320
+ if (entity.type === "SOLID" || entity.type === "TRACE") {
321
+ const corners = entity.corners ?? entity.points;
322
+ if (corners && corners.length >= 4) {
323
+ polyline = [
324
+ [corners[0].x, corners[0].y],
325
+ [corners[1].x, corners[1].y],
326
+ [corners[2].x, corners[2].y],
327
+ [corners[3].x, corners[3].y],
328
+ [corners[0].x, corners[0].y]
329
+ ];
330
+ }
331
+ }
237
332
  if (!polyline) {
238
333
  import_logger.default.warn("unsupported entity for converting to polyline:", entity.type);
239
334
  return [];
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/entityToPolyline.ts"],
4
- "sourcesContent": ["import bSpline from './util/bSpline'\nimport createArcForLWPolyine from './util/createArcForLWPolyline'\nimport logger from './util/logger'\n\nimport type {\n ArcEntity,\n CircleEntity,\n ControlPoint,\n EllipseEntity,\n EntityToPolylineOptions,\n HandlerVertex,\n LineEntity,\n SplineEntity,\n} from './types'\nimport type { PointTuple } from './types/common'\n\n// Re-export types for backward compatibility\nexport type { ControlPoint, EntityToPolylineOptions } from './types'\n\ntype Point = PointTuple\n\n// Local vertex type with required coordinates for runtime processing\ninterface LocalVertex extends HandlerVertex {\n faces?: number[]\n}\n\n// Local polyline type that uses our vertex with required coordinates\ninterface LocalPolylineEntity {\n type: string\n vertices: LocalVertex[]\n closed?: boolean\n polyfaceMesh?: boolean\n polygonMesh?: boolean\n}\n\ntype Entity =\n | LineEntity\n | (LocalPolylineEntity & { type: 'LWPOLYLINE' | 'POLYLINE' })\n | CircleEntity\n | EllipseEntity\n | ArcEntity\n | SplineEntity\n\n/**\n * Rotate a set of points.\n *\n * @param points the points\n * @param angle the rotation angle\n */\nconst rotate = (points: Point[], angle: number): Point[] => {\n return points.map(function (p) {\n return [\n p[0] * Math.cos(angle) - p[1] * Math.sin(angle),\n p[1] * Math.cos(angle) + p[0] * Math.sin(angle),\n ]\n })\n}\n\n/**\n * Interpolate an ellipse\n * @param cx center X\n * @param cy center Y\n * @param rx radius X\n * @param ry radius Y\n * @param start start angle in radians\n * @param start end angle in radians\n */\nconst interpolateEllipse = (\n cx: number,\n cy: number,\n rx: number,\n ry: number,\n start: number,\n end: number,\n rotationAngle?: number\n): Point[] => {\n if (end < start) {\n end += Math.PI * 2\n }\n\n // ----- Relative points -----\n\n // Start point\n let points: Point[] = []\n const dTheta = (Math.PI * 2) / 72\n const EPS = 1e-6\n for (let theta = start; theta < end - EPS; theta += dTheta) {\n points.push([Math.cos(theta) * rx, Math.sin(theta) * ry])\n }\n points.push([Math.cos(end) * rx, Math.sin(end) * ry])\n\n // ----- Rotate -----\n if (rotationAngle) {\n points = rotate(points, rotationAngle)\n }\n\n // ----- Offset center -----\n points = points.map(function (p): Point {\n return [cx + p[0], cy + p[1]]\n })\n\n return points\n}\n\n/**\n * Interpolate a b-spline. The algorithm examins the knot vector\n * to create segments for interpolation. The parameterisation value\n * is re-normalised back to [0,1] as that is what the lib expects (\n * and t i de-normalised in the b-spline library)\n *\n * @param controlPoints the control points\n * @param degree the b-spline degree\n * @param knots the knot vector\n * @returns the polyline\n */\nexport const interpolateBSpline = (\n controlPoints: ControlPoint[],\n degree: number,\n knots: number[],\n interpolationsPerSplineSegment?: number,\n weights?: number[]\n): Point[] => {\n const polyline: Point[] = []\n const controlPointsForLib = controlPoints.map(function (p): Point {\n return [p.x, p.y]\n })\n\n const segmentTs = [knots[degree]]\n const domain: Point = [knots[degree], knots[knots.length - 1 - degree]]\n\n for (let k = degree + 1; k < knots.length - degree; ++k) {\n if (segmentTs[segmentTs.length - 1] !== knots[k]) {\n segmentTs.push(knots[k])\n }\n }\n\n interpolationsPerSplineSegment = interpolationsPerSplineSegment || 25\n for (let i = 1; i < segmentTs.length; ++i) {\n const uMin = segmentTs[i - 1]\n const uMax = segmentTs[i]\n for (let k = 0; k <= interpolationsPerSplineSegment; ++k) {\n const u = (k / interpolationsPerSplineSegment) * (uMax - uMin) + uMin\n // Clamp t to 0, 1 to handle numerical precision issues\n let t = (u - domain[0]) / (domain[1] - domain[0])\n t = Math.max(t, 0)\n t = Math.min(t, 1)\n const p = bSpline(t, degree, controlPointsForLib, knots, weights)\n polyline.push([p[0], p[1]])\n }\n }\n return polyline\n}\n\nexport const polyfaceOutline = (entity: LocalPolylineEntity): Point[][] => {\n const vertices: Array<{ x: number; y: number }> = []\n const faces: Array<{ indices: number[]; hiddens: boolean[] }> = []\n\n for (const v of entity.vertices) {\n if (v.faces) {\n const face: { indices: number[]; hiddens: boolean[] } = {\n indices: [],\n hiddens: [],\n }\n for (const i of v.faces) {\n if (i === 0) {\n break\n }\n // Negative indices signify hidden edges\n face.indices.push(i < 0 ? -i - 1 : i - 1)\n face.hiddens.push(i < 0)\n }\n if ([3, 4].includes(face.indices.length)) faces.push(face)\n } else {\n vertices.push({ x: v.x, y: v.y })\n }\n }\n\n // If a segment starts at the end of a previous line, continue it\n const polylines: number[][] = []\n const segment = (a: number, b: number): void => {\n for (const prev of polylines) {\n if (prev.slice(-1)[0] === a) {\n prev.push(b)\n return\n }\n }\n polylines.push([a, b])\n }\n\n for (const face of faces) {\n for (let beg = 0; beg < face.indices.length; beg++) {\n if (face.hiddens[beg]) {\n continue\n }\n const end = (beg + 1) % face.indices.length\n segment(face.indices[beg], face.indices[end])\n }\n }\n\n // Sometimes segments are not sequential, in that case\n // we need to find if they can mend gaps between others\n for (const a of polylines) {\n for (const b of polylines) {\n if (a !== b && a[0] === b.slice(-1)[0]) {\n b.push(...a.slice(1))\n a.splice(0, a.length)\n break\n }\n }\n }\n\n return polylines\n .filter((l) => l.length)\n .map((l) => l.map((i) => vertices[i]).map((v) => [v.x, v.y]))\n}\n\n/**\n * Convert a parsed DXF entity to a polyline. These can be used to render the\n * the DXF in SVG, Canvas, WebGL etc., without depending on native support\n * of primitive objects (ellispe, spline etc.)\n */\nexport default function entityToPolyline(\n entity: Entity,\n options?: EntityToPolylineOptions,\n): Point[] {\n options = options || {}\n let polyline: Point[] | undefined\n\n if (entity.type === 'LINE') {\n polyline = [\n [entity.start.x, entity.start.y],\n [entity.end.x, entity.end.y],\n ]\n }\n\n if (entity.type === 'LWPOLYLINE' || entity.type === 'POLYLINE') {\n polyline = []\n if (entity.polyfaceMesh) {\n // Only return the first polyline because we can't return many\n polyline.push(...polyfaceOutline(entity)[0])\n } else if (entity.polygonMesh) {\n // Do not attempt to render polygon meshes\n } else if (entity.vertices.length) {\n if (entity.closed) {\n entity.vertices = entity.vertices.concat(entity.vertices[0])\n }\n for (let i = 0, il = entity.vertices.length; i < il - 1; ++i) {\n const from: Point = [entity.vertices[i].x, entity.vertices[i].y]\n const to: Point = [entity.vertices[i + 1].x, entity.vertices[i + 1].y]\n polyline.push(from)\n if (entity.vertices[i].bulge) {\n polyline = polyline.concat(\n createArcForLWPolyine(from, to, entity.vertices[i].bulge!),\n )\n }\n // The last iteration of the for loop\n if (i === il - 2) {\n polyline.push(to)\n }\n }\n } else {\n logger.warn('Polyline entity with no vertices')\n }\n }\n\n if (entity.type === 'CIRCLE') {\n polyline = interpolateEllipse(\n entity.x,\n entity.y,\n entity.r,\n entity.r,\n 0,\n Math.PI * 2,\n )\n if (entity.extrusionZ === -1) {\n polyline = polyline.map(function (p): Point {\n return [-p[0], p[1]]\n })\n }\n }\n\n if (entity.type === 'ELLIPSE') {\n const rx = Math.hypot(entity.majorX, entity.majorY)\n const ry = entity.axisRatio * rx\n const majorAxisRotation = -Math.atan2(-entity.majorY, entity.majorX)\n polyline = interpolateEllipse(\n entity.x,\n entity.y,\n rx,\n ry,\n entity.startAngle,\n entity.endAngle,\n majorAxisRotation,\n )\n if (entity.extrusionZ === -1) {\n polyline = polyline.map(function (p): Point {\n return [-p[0], p[1]]\n })\n }\n }\n\n if (entity.type === 'ARC') {\n // Why on earth DXF has degree start & end angles for arc,\n // and radian start & end angles for ellipses is a mystery\n polyline = interpolateEllipse(\n entity.x,\n entity.y,\n entity.r,\n entity.r,\n entity.startAngle,\n entity.endAngle,\n )\n\n // I kid you not, ARCs and ELLIPSEs handle this differently,\n // as evidenced by how AutoCAD actually renders these entities\n if (entity.extrusionZ === -1) {\n polyline = polyline.map(function (p): Point {\n return [-p[0], p[1]]\n })\n }\n }\n\n if (entity.type === 'SPLINE') {\n polyline = interpolateBSpline(\n entity.controlPoints,\n entity.degree,\n entity.knots,\n options.interpolationsPerSplineSegment,\n entity.weights,\n )\n }\n\n if (!polyline) {\n logger.warn('unsupported entity for converting to polyline:', entity.type)\n return []\n }\n return polyline\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAoB;AACpB,oCAAkC;AAClC,oBAAmB;AA+CnB,MAAM,SAAS,CAAC,QAAiB,UAA2B;AAC1D,SAAO,OAAO,IAAI,SAAU,GAAG;AAC7B,WAAO;AAAA,MACL,EAAE,CAAC,IAAI,KAAK,IAAI,KAAK,IAAI,EAAE,CAAC,IAAI,KAAK,IAAI,KAAK;AAAA,MAC9C,EAAE,CAAC,IAAI,KAAK,IAAI,KAAK,IAAI,EAAE,CAAC,IAAI,KAAK,IAAI,KAAK;AAAA,IAChD;AAAA,EACF,CAAC;AACH;AAWA,MAAM,qBAAqB,CACzB,IACA,IACA,IACA,IACA,OACA,KACA,kBACY;AACZ,MAAI,MAAM,OAAO;AACf,WAAO,KAAK,KAAK;AAAA,EACnB;AAKA,MAAI,SAAkB,CAAC;AACvB,QAAM,SAAU,KAAK,KAAK,IAAK;AAC/B,QAAM,MAAM;AACZ,WAAS,QAAQ,OAAO,QAAQ,MAA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,CAAC;AAAA,MACrB,CAAC;AAAA,IACH;AAAA,EACF;AAEA,MAAI,OAAO,SAAS,OAAO;AAGzB,eAAW;AAAA,MACT,OAAO;AAAA,MACP,OAAO;AAAA,MACP,OAAO;AAAA,MACP,OAAO;AAAA,MACP,OAAO;AAAA,MACP,OAAO;AAAA,IACT;AAIA,QAAI,OAAO,eAAe,IAAI;AAC5B,iBAAW,SAAS,IAAI,SAAU,GAAU;AAC1C,eAAO,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;AAAA,MACrB,CAAC;AAAA,IACH;AAAA,EACF;AAEA,MAAI,OAAO,SAAS,UAAU;AAC5B,eAAW;AAAA,MACT,OAAO;AAAA,MACP,OAAO;AAAA,MACP,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,OAAO;AAAA,IACT;AAAA,EACF;AAEA,MAAI,CAAC,UAAU;AACb,kBAAAA,QAAO,KAAK,kDAAkD,OAAO,IAAI;AACzE,WAAO,CAAC;AAAA,EACV;AACA,SAAO;AACT;",
6
- "names": ["bSpline", "createArcForLWPolyine", "logger"]
4
+ "sourcesContent": ["import bSpline from './util/bSpline'\nimport createArcForLWPolyine from './util/createArcForLWPolyline'\nimport logger from './util/logger'\n\nimport type {\n ArcEntity,\n CircleEntity,\n ControlPoint,\n EllipseEntity,\n EntityToPolylineOptions,\n HandlerVertex,\n LeaderEntity,\n LineEntity,\n RayEntity,\n ShapeEntity,\n SplineEntity,\n WipeoutEntity,\n XLineEntity,\n} from './types'\nimport type { PointTuple } from './types/common'\n\n// Re-export types for backward compatibility\nexport type { ControlPoint, EntityToPolylineOptions } from './types'\n\ntype Point = PointTuple\n\n// Local vertex type with required coordinates for runtime processing\ninterface LocalVertex extends HandlerVertex {\n faces?: number[]\n}\n\n// Local polyline type that uses our vertex with required coordinates\ninterface LocalPolylineEntity {\n type: string\n vertices: LocalVertex[]\n closed?: boolean\n polyfaceMesh?: boolean\n polygonMesh?: boolean\n}\n\ntype Entity =\n | LineEntity\n | LeaderEntity\n | RayEntity\n | XLineEntity\n | ShapeEntity\n | WipeoutEntity\n | (LocalPolylineEntity & { type: 'LWPOLYLINE' | 'POLYLINE' })\n | {\n type: 'SOLID' | 'TRACE'\n corners?: Array<{ x: number; y: number }>\n points?: Array<{ x: number; y: number }>\n }\n | CircleEntity\n | EllipseEntity\n | ArcEntity\n | SplineEntity\n\n/**\n * Rotate a set of points.\n *\n * @param points the points\n * @param angle the rotation angle\n */\nconst rotate = (points: Point[], angle: number): Point[] => {\n return points.map(function (p) {\n return [\n p[0] * Math.cos(angle) - p[1] * Math.sin(angle),\n p[1] * Math.cos(angle) + p[0] * Math.sin(angle),\n ]\n })\n}\n\n/**\n * Interpolate an ellipse\n * @param cx center X\n * @param cy center Y\n * @param rx radius X\n * @param ry radius Y\n * @param start start angle in radians\n * @param start end angle in radians\n */\nconst interpolateEllipse = (\n cx: number,\n cy: number,\n rx: number,\n ry: number,\n start: number,\n end: number,\n rotationAngle?: number\n): Point[] => {\n if (end < start) {\n end += Math.PI * 2\n }\n\n // ----- Relative points -----\n\n // Start point\n let points: Point[] = []\n const dTheta = (Math.PI * 2) / 72\n const EPS = 1e-6\n for (let theta = start; theta < end - EPS; theta += dTheta) {\n points.push([Math.cos(theta) * rx, Math.sin(theta) * ry])\n }\n points.push([Math.cos(end) * rx, Math.sin(end) * ry])\n\n // ----- Rotate -----\n if (rotationAngle) {\n points = rotate(points, rotationAngle)\n }\n\n // ----- Offset center -----\n points = points.map(function (p): Point {\n return [cx + p[0], cy + p[1]]\n })\n\n return points\n}\n\n/**\n * Interpolate a b-spline. The algorithm examins the knot vector\n * to create segments for interpolation. The parameterisation value\n * is re-normalised back to [0,1] as that is what the lib expects (\n * and t i de-normalised in the b-spline library)\n *\n * @param controlPoints the control points\n * @param degree the b-spline degree\n * @param knots the knot vector\n * @returns the polyline\n */\nexport const interpolateBSpline = (\n controlPoints: ControlPoint[],\n degree: number,\n knots: number[],\n interpolationsPerSplineSegment?: number,\n weights?: number[]\n): Point[] => {\n const polyline: Point[] = []\n const controlPointsForLib = controlPoints.map(function (p): Point {\n return [p.x, p.y]\n })\n\n const segmentTs = [knots[degree]]\n const domain: Point = [knots[degree], knots[knots.length - 1 - degree]]\n\n for (let k = degree + 1; k < knots.length - degree; ++k) {\n if (segmentTs[segmentTs.length - 1] !== knots[k]) {\n segmentTs.push(knots[k])\n }\n }\n\n interpolationsPerSplineSegment = interpolationsPerSplineSegment || 25\n for (let i = 1; i < segmentTs.length; ++i) {\n const uMin = segmentTs[i - 1]\n const uMax = segmentTs[i]\n for (let k = 0; k <= interpolationsPerSplineSegment; ++k) {\n const u = (k / interpolationsPerSplineSegment) * (uMax - uMin) + uMin\n // Clamp t to 0, 1 to handle numerical precision issues\n let t = (u - domain[0]) / (domain[1] - domain[0])\n t = Math.max(t, 0)\n t = Math.min(t, 1)\n const p = bSpline(t, degree, controlPointsForLib, knots, weights)\n polyline.push([p[0], p[1]])\n }\n }\n return polyline\n}\n\nexport const polyfaceOutline = (entity: LocalPolylineEntity): Point[][] => { // NOSONAR\n const vertices: Array<{ x: number; y: number }> = []\n const faces: Array<{ indices: number[]; hiddens: boolean[] }> = []\n\n for (const v of entity.vertices) {\n if (v.faces) {\n const face: { indices: number[]; hiddens: boolean[] } = {\n indices: [],\n hiddens: [],\n }\n for (const i of v.faces) {\n if (i === 0) {\n break\n }\n // Negative indices signify hidden edges\n face.indices.push(i < 0 ? -i - 1 : i - 1)\n face.hiddens.push(i < 0)\n }\n if ([3, 4].includes(face.indices.length)) faces.push(face)\n } else {\n vertices.push({ x: v.x, y: v.y })\n }\n }\n\n // If a segment starts at the end of a previous line, continue it\n const polylines: number[][] = []\n const segment = (a: number, b: number): void => {\n for (const prev of polylines) {\n if (prev.slice(-1)[0] === a) {\n prev.push(b)\n return\n }\n }\n polylines.push([a, b])\n }\n\n for (const face of faces) {\n for (let beg = 0; beg < face.indices.length; beg++) {\n if (face.hiddens[beg]) {\n continue\n }\n const end = (beg + 1) % face.indices.length\n segment(face.indices[beg], face.indices[end])\n }\n }\n\n // Sometimes segments are not sequential, in that case\n // we need to find if they can mend gaps between others\n for (const a of polylines) {\n for (const b of polylines) {\n if (a !== b && a[0] === b.slice(-1)[0]) {\n b.push(...a.slice(1))\n a.splice(0, a.length)\n break\n }\n }\n }\n\n return polylines\n .filter((l) => l.length)\n .map((l) => l.map((i) => vertices[i]).map((v) => [v.x, v.y]))\n}\n\n/**\n * Convert a parsed DXF entity to a polyline. These can be used to render the\n * the DXF in SVG, Canvas, WebGL etc., without depending on native support\n * of primitive objects (ellispe, spline etc.)\n */\nexport default function entityToPolyline( // NOSONAR\n entity: Entity,\n options?: EntityToPolylineOptions,\n): Point[] {\n options = options || {}\n let polyline: Point[] | undefined\n\n const INFINITE_LINE_LENGTH = 1000\n\n const normalize2 = (x: number, y: number): { x: number; y: number } | null => {\n const len = Math.hypot(x, y)\n if (len === 0) return null\n return { x: x / len, y: y / len }\n }\n\n if (entity.type === 'LINE') {\n polyline = [\n [entity.start.x, entity.start.y],\n [entity.end.x, entity.end.y],\n ]\n }\n\n if (entity.type === 'LEADER') {\n if (entity.vertices.length >= 2) {\n polyline = entity.vertices.map((v) => [v.x, v.y])\n } else {\n logger.warn('LEADER entity with insufficient vertices')\n polyline = []\n }\n }\n\n if (entity.type === 'RAY') {\n const dir = normalize2(entity.direction.x, entity.direction.y)\n if (dir === null) {\n logger.warn('RAY entity with zero direction vector')\n polyline = []\n } else {\n polyline = [\n [entity.start.x, entity.start.y],\n [\n entity.start.x + dir.x * INFINITE_LINE_LENGTH,\n entity.start.y + dir.y * INFINITE_LINE_LENGTH,\n ],\n ]\n }\n }\n\n if (entity.type === 'XLINE') {\n const dir = normalize2(entity.direction.x, entity.direction.y)\n if (dir === null) {\n logger.warn('XLINE entity with zero direction vector')\n polyline = []\n } else {\n polyline = [\n [\n entity.basePoint.x - dir.x * INFINITE_LINE_LENGTH,\n entity.basePoint.y - dir.y * INFINITE_LINE_LENGTH,\n ],\n [\n entity.basePoint.x + dir.x * INFINITE_LINE_LENGTH,\n entity.basePoint.y + dir.y * INFINITE_LINE_LENGTH,\n ],\n ]\n }\n }\n\n if (entity.type === 'SHAPE') {\n const x = entity.insertionPoint?.x ?? 0\n const y = entity.insertionPoint?.y ?? 0\n const size = entity.size ?? 0\n const scaleX = entity.relativeXScale ?? 1\n const length = size * scaleX\n polyline = [\n [x, y],\n [x + length, y],\n ]\n }\n\n if (entity.type === 'WIPEOUT') {\n const verts = entity.clipBoundaryVertices\n if (!verts || verts.length < 2) {\n logger.warn('WIPEOUT entity with missing clip boundary vertices')\n polyline = []\n } else {\n const insX = entity.insertionPoint?.x ?? 0\n const insY = entity.insertionPoint?.y ?? 0\n\n const ux = entity.uVector?.x ?? 1\n const uy = entity.uVector?.y ?? 0\n\n const vx = entity.vVector?.x ?? 0\n const vy = entity.vVector?.y ?? 1\n\n polyline = verts.map((p) => [\n insX + ux * p.x + vx * p.y,\n insY + uy * p.x + vy * p.y,\n ])\n\n if (polyline.length > 0) {\n const first = polyline[0]\n const last = polyline[polyline.length - 1]\n if (first[0] !== last[0] || first[1] !== last[1]) {\n polyline.push(first)\n }\n }\n }\n }\n\n if (entity.type === 'LWPOLYLINE' || entity.type === 'POLYLINE') {\n polyline = []\n if (entity.polyfaceMesh) {\n // Only return the first polyline because we can't return many\n polyline.push(...polyfaceOutline(entity)[0])\n } else if (entity.polygonMesh) {\n // Do not attempt to render polygon meshes\n } else if (entity.vertices.length) {\n if (entity.closed) {\n entity.vertices = entity.vertices.concat(entity.vertices[0])\n }\n for (let i = 0, il = entity.vertices.length; i < il - 1; ++i) {\n const from: Point = [entity.vertices[i].x, entity.vertices[i].y]\n const to: Point = [entity.vertices[i + 1].x, entity.vertices[i + 1].y]\n polyline.push(from)\n if (entity.vertices[i].bulge) {\n polyline = polyline.concat(\n createArcForLWPolyine(from, to, entity.vertices[i].bulge!),\n )\n }\n // The last iteration of the for loop\n if (i === il - 2) {\n polyline.push(to)\n }\n }\n } else {\n logger.warn('Polyline entity with no vertices')\n }\n }\n\n if (entity.type === 'CIRCLE') {\n polyline = interpolateEllipse(\n entity.x,\n entity.y,\n entity.r,\n entity.r,\n 0,\n Math.PI * 2,\n )\n if (entity.extrusionZ === -1) {\n polyline = polyline.map(function (p): Point {\n return [-p[0], p[1]]\n })\n }\n }\n\n if (entity.type === 'ELLIPSE') {\n const rx = Math.hypot(entity.majorX, entity.majorY)\n const ry = entity.axisRatio * rx\n const majorAxisRotation = -Math.atan2(-entity.majorY, entity.majorX)\n polyline = interpolateEllipse(\n entity.x,\n entity.y,\n rx,\n ry,\n entity.startAngle,\n entity.endAngle,\n majorAxisRotation,\n )\n if (entity.extrusionZ === -1) {\n polyline = polyline.map(function (p): Point {\n return [-p[0], p[1]]\n })\n }\n }\n\n if (entity.type === 'ARC') {\n // Why on earth DXF has degree start & end angles for arc,\n // and radian start & end angles for ellipses is a mystery\n polyline = interpolateEllipse(\n entity.x,\n entity.y,\n entity.r,\n entity.r,\n entity.startAngle,\n entity.endAngle,\n )\n\n // I kid you not, ARCs and ELLIPSEs handle this differently,\n // as evidenced by how AutoCAD actually renders these entities\n if (entity.extrusionZ === -1) {\n polyline = polyline.map(function (p): Point {\n return [-p[0], p[1]]\n })\n }\n }\n\n if (entity.type === 'SPLINE') {\n polyline = interpolateBSpline(\n entity.controlPoints,\n entity.degree,\n entity.knots,\n options.interpolationsPerSplineSegment,\n entity.weights,\n )\n }\n\n if (entity.type === 'SOLID' || entity.type === 'TRACE') {\n const corners = entity.corners ?? entity.points\n if (corners && corners.length >= 4) {\n polyline = [\n [corners[0].x, corners[0].y],\n [corners[1].x, corners[1].y],\n [corners[2].x, corners[2].y],\n [corners[3].x, corners[3].y],\n [corners[0].x, corners[0].y],\n ]\n }\n }\n\n if (!polyline) {\n logger.warn('unsupported entity for converting to polyline:', entity.type)\n return []\n }\n return polyline\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;A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,EAAE,CAAC;AAAA,QAC3B,CAAC,QAAQ,CAAC,EAAE,GAAG,QAAQ,CAAC,EAAE,CAAC;AAAA,QAC3B,CAAC,QAAQ,CAAC,EAAE,GAAG,QAAQ,CAAC,EAAE,CAAC;AAAA,QAC3B,CAAC,QAAQ,CAAC,EAAE,GAAG,QAAQ,CAAC,EAAE,CAAC;AAAA,QAC3B,CAAC,QAAQ,CAAC,EAAE,GAAG,QAAQ,CAAC,EAAE,CAAC;AAAA,MAC7B;AAAA,IACF;AAAA,EACF;AAEA,MAAI,CAAC,UAAU;AACb,kBAAAA,QAAO,KAAK,kDAAkD,OAAO,IAAI;AACzE,WAAO,CAAC;AAAA,EACV;AACA,SAAO;AACT;",
6
+ "names": ["bSpline", "logger", "createArcForLWPolyine"]
7
7
  }
@@ -0,0 +1,48 @@
1
+ import type { ArcEntity, CircleEntity, ControlPoint, EllipseEntity, EntityToPolylineOptions, HandlerVertex, LeaderEntity, LineEntity, RayEntity, ShapeEntity, SplineEntity, WipeoutEntity, XLineEntity } from './types';
2
+ import type { PointTuple } from './types/common';
3
+ export type { ControlPoint, EntityToPolylineOptions } from './types';
4
+ type Point = PointTuple;
5
+ interface LocalVertex extends HandlerVertex {
6
+ faces?: number[];
7
+ }
8
+ interface LocalPolylineEntity {
9
+ type: string;
10
+ vertices: LocalVertex[];
11
+ closed?: boolean;
12
+ polyfaceMesh?: boolean;
13
+ polygonMesh?: boolean;
14
+ }
15
+ type Entity = LineEntity | LeaderEntity | RayEntity | XLineEntity | ShapeEntity | WipeoutEntity | (LocalPolylineEntity & {
16
+ type: 'LWPOLYLINE' | 'POLYLINE';
17
+ }) | {
18
+ type: 'SOLID' | 'TRACE';
19
+ corners?: Array<{
20
+ x: number;
21
+ y: number;
22
+ }>;
23
+ points?: Array<{
24
+ x: number;
25
+ y: number;
26
+ }>;
27
+ } | CircleEntity | EllipseEntity | ArcEntity | SplineEntity;
28
+ /**
29
+ * Interpolate a b-spline. The algorithm examins the knot vector
30
+ * to create segments for interpolation. The parameterisation value
31
+ * is re-normalised back to [0,1] as that is what the lib expects (
32
+ * and t i de-normalised in the b-spline library)
33
+ *
34
+ * @param controlPoints the control points
35
+ * @param degree the b-spline degree
36
+ * @param knots the knot vector
37
+ * @returns the polyline
38
+ */
39
+ export declare const interpolateBSpline: (controlPoints: ControlPoint[], degree: number, knots: number[], interpolationsPerSplineSegment?: number, weights?: number[]) => Point[];
40
+ export declare const polyfaceOutline: (entity: LocalPolylineEntity) => Point[][];
41
+ /**
42
+ * Convert a parsed DXF entity to a polyline. These can be used to render the
43
+ * the DXF in SVG, Canvas, WebGL etc., without depending on native support
44
+ * of primitive objects (ellispe, spline etc.)
45
+ */
46
+ export default function entityToPolyline(// NOSONAR
47
+ entity: Entity, options?: EntityToPolylineOptions): Point[];
48
+ //# sourceMappingURL=entityToPolyline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entityToPolyline.d.ts","sourceRoot":"","sources":["../src/entityToPolyline.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,uBAAuB,EACvB,aAAa,EACb,YAAY,EACZ,UAAU,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,aAAa,EACb,WAAW,EACZ,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAGhD,YAAY,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA;AAEpE,KAAK,KAAK,GAAG,UAAU,CAAA;AAGvB,UAAU,WAAY,SAAQ,aAAa;IACzC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;CACjB;AAGD,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,WAAW,EAAE,CAAA;IACvB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED,KAAK,MAAM,GACP,UAAU,GACV,YAAY,GACZ,SAAS,GACT,WAAW,GACX,WAAW,GACX,aAAa,GACb,CAAC,mBAAmB,GAAG;IAAE,IAAI,EAAE,YAAY,GAAG,UAAU,CAAA;CAAE,CAAC,GAC3D;IACE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAA;IACvB,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACzC,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACzC,GACD,YAAY,GACZ,aAAa,GACb,SAAS,GACT,YAAY,CAAA;AA+DhB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,GAC7B,eAAe,YAAY,EAAE,EAC7B,QAAQ,MAAM,EACd,OAAO,MAAM,EAAE,EACf,iCAAiC,MAAM,EACvC,UAAU,MAAM,EAAE,KACjB,KAAK,EA8BP,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,QAAQ,mBAAmB,KAAG,KAAK,EAAE,EA6DpE,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAE,UAAU;AAClD,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,uBAAuB,GAChC,KAAK,EAAE,CA4NT"}
@@ -109,12 +109,95 @@ const polyfaceOutline = (entity) => {
109
109
  function entityToPolyline(entity, options) {
110
110
  options = options || {};
111
111
  let polyline;
112
+ const INFINITE_LINE_LENGTH = 1e3;
113
+ const normalize2 = (x, y) => {
114
+ const len = Math.hypot(x, y);
115
+ if (len === 0) return null;
116
+ return { x: x / len, y: y / len };
117
+ };
112
118
  if (entity.type === "LINE") {
113
119
  polyline = [
114
120
  [entity.start.x, entity.start.y],
115
121
  [entity.end.x, entity.end.y]
116
122
  ];
117
123
  }
124
+ if (entity.type === "LEADER") {
125
+ if (entity.vertices.length >= 2) {
126
+ polyline = entity.vertices.map((v) => [v.x, v.y]);
127
+ } else {
128
+ logger.warn("LEADER entity with insufficient vertices");
129
+ polyline = [];
130
+ }
131
+ }
132
+ if (entity.type === "RAY") {
133
+ const dir = normalize2(entity.direction.x, entity.direction.y);
134
+ if (dir === null) {
135
+ logger.warn("RAY entity with zero direction vector");
136
+ polyline = [];
137
+ } else {
138
+ polyline = [
139
+ [entity.start.x, entity.start.y],
140
+ [
141
+ entity.start.x + dir.x * INFINITE_LINE_LENGTH,
142
+ entity.start.y + dir.y * INFINITE_LINE_LENGTH
143
+ ]
144
+ ];
145
+ }
146
+ }
147
+ if (entity.type === "XLINE") {
148
+ const dir = normalize2(entity.direction.x, entity.direction.y);
149
+ if (dir === null) {
150
+ logger.warn("XLINE entity with zero direction vector");
151
+ polyline = [];
152
+ } else {
153
+ polyline = [
154
+ [
155
+ entity.basePoint.x - dir.x * INFINITE_LINE_LENGTH,
156
+ entity.basePoint.y - dir.y * INFINITE_LINE_LENGTH
157
+ ],
158
+ [
159
+ entity.basePoint.x + dir.x * INFINITE_LINE_LENGTH,
160
+ entity.basePoint.y + dir.y * INFINITE_LINE_LENGTH
161
+ ]
162
+ ];
163
+ }
164
+ }
165
+ if (entity.type === "SHAPE") {
166
+ const x = entity.insertionPoint?.x ?? 0;
167
+ const y = entity.insertionPoint?.y ?? 0;
168
+ const size = entity.size ?? 0;
169
+ const scaleX = entity.relativeXScale ?? 1;
170
+ const length = size * scaleX;
171
+ polyline = [
172
+ [x, y],
173
+ [x + length, y]
174
+ ];
175
+ }
176
+ if (entity.type === "WIPEOUT") {
177
+ const verts = entity.clipBoundaryVertices;
178
+ if (!verts || verts.length < 2) {
179
+ logger.warn("WIPEOUT entity with missing clip boundary vertices");
180
+ polyline = [];
181
+ } else {
182
+ const insX = entity.insertionPoint?.x ?? 0;
183
+ const insY = entity.insertionPoint?.y ?? 0;
184
+ const ux = entity.uVector?.x ?? 1;
185
+ const uy = entity.uVector?.y ?? 0;
186
+ const vx = entity.vVector?.x ?? 0;
187
+ const vy = entity.vVector?.y ?? 1;
188
+ polyline = verts.map((p) => [
189
+ insX + ux * p.x + vx * p.y,
190
+ insY + uy * p.x + vy * p.y
191
+ ]);
192
+ if (polyline.length > 0) {
193
+ const first = polyline[0];
194
+ const last = polyline[polyline.length - 1];
195
+ if (first[0] !== last[0] || first[1] !== last[1]) {
196
+ polyline.push(first);
197
+ }
198
+ }
199
+ }
200
+ }
118
201
  if (entity.type === "LWPOLYLINE" || entity.type === "POLYLINE") {
119
202
  polyline = [];
120
203
  if (entity.polyfaceMesh) {
@@ -199,6 +282,18 @@ function entityToPolyline(entity, options) {
199
282
  entity.weights
200
283
  );
201
284
  }
285
+ if (entity.type === "SOLID" || entity.type === "TRACE") {
286
+ const corners = entity.corners ?? entity.points;
287
+ if (corners && corners.length >= 4) {
288
+ polyline = [
289
+ [corners[0].x, corners[0].y],
290
+ [corners[1].x, corners[1].y],
291
+ [corners[2].x, corners[2].y],
292
+ [corners[3].x, corners[3].y],
293
+ [corners[0].x, corners[0].y]
294
+ ];
295
+ }
296
+ }
202
297
  if (!polyline) {
203
298
  logger.warn("unsupported entity for converting to polyline:", entity.type);
204
299
  return [];