kitchen-simulator 1.1.1-test.49 → 1.1.1-test.50

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 (358) hide show
  1. package/es/@history.js +2 -0
  2. package/es/AppContext.js +3 -0
  3. package/es/KitchenConfigurator.js +645 -0
  4. package/es/KitchenConfiguratorApp.js +480 -0
  5. package/es/actions/area-actions.js +14 -0
  6. package/es/actions/export.js +23 -0
  7. package/es/actions/groups-actions.js +89 -0
  8. package/es/actions/holes-actions.js +119 -0
  9. package/es/actions/items-actions.js +313 -0
  10. package/es/actions/lines-actions.js +81 -0
  11. package/es/actions/project-actions.js +281 -0
  12. package/es/actions/scene-actions.js +33 -0
  13. package/es/actions/vertices-actions.js +27 -0
  14. package/es/actions/viewer2d-actions.js +58 -0
  15. package/es/actions/viewer3d-actions.js +23 -0
  16. package/es/catalog/areas/area/planner-element.js +40 -0
  17. package/es/catalog/areas/area/textures/ceramic-tile.jpg +0 -0
  18. package/es/catalog/areas/area/textures/grass.jpg +0 -0
  19. package/es/catalog/areas/area/textures/parquet.jpg +0 -0
  20. package/es/catalog/areas/area/textures/strand-porcelain.jpg +0 -0
  21. package/es/catalog/areas/area/textures/tile1.jpg +0 -0
  22. package/es/catalog/catalog.js +277 -0
  23. package/es/catalog/envMap/nx.hdr +0 -0
  24. package/es/catalog/envMap/ny.hdr +0 -0
  25. package/es/catalog/envMap/nz.hdr +0 -0
  26. package/es/catalog/envMap/px.hdr +0 -0
  27. package/es/catalog/envMap/py.hdr +0 -0
  28. package/es/catalog/envMap/pz.hdr +0 -0
  29. package/es/catalog/factories/area-factory-3d.js +181 -0
  30. package/es/catalog/factories/area-factory.js +81 -0
  31. package/es/catalog/factories/export.js +7 -0
  32. package/es/catalog/factories/wall-factory-3d.js +202 -0
  33. package/es/catalog/factories/wall-factory.js +268 -0
  34. package/es/catalog/holes/door-closet/planner-element.js +222 -0
  35. package/es/catalog/holes/door-double/door_double.png +0 -0
  36. package/es/catalog/holes/door-double/planner-element.js +315 -0
  37. package/es/catalog/holes/door-exterior/planner-element.js +215 -0
  38. package/es/catalog/holes/door-interior/planner-element.js +227 -0
  39. package/es/catalog/holes/door-panic/panicDoor.png +0 -0
  40. package/es/catalog/holes/door-panic/planner-element.js +503 -0
  41. package/es/catalog/holes/door-panic-double/panicDoorDouble.png +0 -0
  42. package/es/catalog/holes/door-panic-double/planner-element.js +463 -0
  43. package/es/catalog/holes/door-sliding/planner-element.js +225 -0
  44. package/es/catalog/holes/doorway-framed/planner-element.js +145 -0
  45. package/es/catalog/holes/doorway-frameless/planner-element.js +104 -0
  46. package/es/catalog/holes/export.js +13 -0
  47. package/es/catalog/holes/gate/gate.jpg +0 -0
  48. package/es/catalog/holes/window-clear/planner-element.js +166 -0
  49. package/es/catalog/holes/window-clear/texture.png +0 -0
  50. package/es/catalog/holes/window-cross/planner-element.js +165 -0
  51. package/es/catalog/holes/window-cross/texture.png +0 -0
  52. package/es/catalog/holes/window-double-hung/planner-element.js +303 -0
  53. package/es/catalog/holes/window-double-hung/texture.png +0 -0
  54. package/es/catalog/holes/window-vertical/planner-element.js +276 -0
  55. package/es/catalog/holes/window-vertical/texture.png +0 -0
  56. package/es/catalog/lines/wall/planner-element.js +70 -0
  57. package/es/catalog/lines/wall/textures/bricks-normal.jpg +0 -0
  58. package/es/catalog/lines/wall/textures/bricks-normal2.jpg +0 -0
  59. package/es/catalog/lines/wall/textures/bricks.jpg +0 -0
  60. package/es/catalog/lines/wall/textures/bricks2.jpg +0 -0
  61. package/es/catalog/lines/wall/textures/bricks3.jpg +0 -0
  62. package/es/catalog/lines/wall/textures/morden-normal.jpg +0 -0
  63. package/es/catalog/lines/wall/textures/morden.jpg +0 -0
  64. package/es/catalog/lines/wall/textures/painted-normal.jpg +0 -0
  65. package/es/catalog/lines/wall/textures/painted.jpg +0 -0
  66. package/es/catalog/lines/wall/textures/plaster-normal.jpg +0 -0
  67. package/es/catalog/lines/wall/textures/plaster.jpg +0 -0
  68. package/es/catalog/lines/wall/wall.png +0 -0
  69. package/es/catalog/molding/molding-dcm/planner-element.js +28 -0
  70. package/es/catalog/molding/molding-dcm/texture.png +0 -0
  71. package/es/catalog/molding/molding-fbm/planner-element.js +28 -0
  72. package/es/catalog/molding/molding-fbm/texture.png +0 -0
  73. package/es/catalog/molding/molding-lrm/planner-element.js +28 -0
  74. package/es/catalog/molding/molding-lrm/texture.png +0 -0
  75. package/es/catalog/properties/export.js +21 -0
  76. package/es/catalog/properties/property-checkbox.js +116 -0
  77. package/es/catalog/properties/property-color.js +39 -0
  78. package/es/catalog/properties/property-enum.js +97 -0
  79. package/es/catalog/properties/property-hidden.js +19 -0
  80. package/es/catalog/properties/property-lenght-measure.js +101 -0
  81. package/es/catalog/properties/property-length-measure.js +134 -0
  82. package/es/catalog/properties/property-length-measure_hole.js +101 -0
  83. package/es/catalog/properties/property-number.js +48 -0
  84. package/es/catalog/properties/property-read-only.js +26 -0
  85. package/es/catalog/properties/property-string.js +48 -0
  86. package/es/catalog/properties/property-toggle.js +39 -0
  87. package/es/catalog/properties/shared-property-style.js +14 -0
  88. package/es/catalog/utils/FuseUtils.js +82 -0
  89. package/es/catalog/utils/exporter.js +148 -0
  90. package/es/catalog/utils/geom-utils.js +189 -0
  91. package/es/catalog/utils/item-loader.js +1521 -0
  92. package/es/catalog/utils/load-obj.js +91 -0
  93. package/es/catalog/utils/mtl-loader.js +358 -0
  94. package/es/catalog/utils/obj-loader.js +477 -0
  95. package/es/class/FuseUtils.js +82 -0
  96. package/es/class/area.js +145 -0
  97. package/es/class/export.js +24 -0
  98. package/es/class/group.js +440 -0
  99. package/es/class/guide.js +62 -0
  100. package/es/class/hole.js +929 -0
  101. package/es/class/item.js +1883 -0
  102. package/es/class/layer.js +667 -0
  103. package/es/class/line.js +1180 -0
  104. package/es/class/project.js +793 -0
  105. package/es/class/vertex.js +202 -0
  106. package/es/components/content.js +107 -0
  107. package/es/components/disclaimer/disclaimer.js +97 -0
  108. package/es/components/export.js +9 -0
  109. package/es/components/style/button.js +113 -0
  110. package/es/components/style/cancel-button.js +22 -0
  111. package/es/components/style/content-container.js +33 -0
  112. package/es/components/style/content-title.js +29 -0
  113. package/es/components/style/delete-button.js +25 -0
  114. package/es/components/style/export.js +31 -0
  115. package/es/components/style/form-block.js +24 -0
  116. package/es/components/style/form-color-input.js +27 -0
  117. package/es/components/style/form-label.js +26 -0
  118. package/es/components/style/form-number-input.js +213 -0
  119. package/es/components/style/form-number-input_2.js +206 -0
  120. package/es/components/style/form-select.js +68 -0
  121. package/es/components/style/form-slider.js +61 -0
  122. package/es/components/style/form-submit-button.js +26 -0
  123. package/es/components/style/form-text-input.js +95 -0
  124. package/es/components/viewer2d/area.js +81 -0
  125. package/es/components/viewer2d/export.js +31 -0
  126. package/es/components/viewer2d/grids/grid-horizontal-streak.js +37 -0
  127. package/es/components/viewer2d/grids/grid-streak.js +37 -0
  128. package/es/components/viewer2d/grids/grid-vertical-streak.js +37 -0
  129. package/es/components/viewer2d/grids/grids.js +35 -0
  130. package/es/components/viewer2d/group.js +53 -0
  131. package/es/components/viewer2d/item.js +513 -0
  132. package/es/components/viewer2d/layer.js +164 -0
  133. package/es/components/viewer2d/line.js +882 -0
  134. package/es/components/viewer2d/ruler.js +100 -0
  135. package/es/components/viewer2d/rulerDist.js +146 -0
  136. package/es/components/viewer2d/rulerX.js +151 -0
  137. package/es/components/viewer2d/rulerY.js +153 -0
  138. package/es/components/viewer2d/scene.js +140 -0
  139. package/es/components/viewer2d/snap.js +74 -0
  140. package/es/components/viewer2d/state.js +78 -0
  141. package/es/components/viewer2d/utils.js +198 -0
  142. package/es/components/viewer2d/vertex.js +65 -0
  143. package/es/components/viewer2d/viewer2d.js +1398 -0
  144. package/es/components/viewer3d/camera-controls-module/camera-controls.module.js +2592 -0
  145. package/es/components/viewer3d/dcm.js +401 -0
  146. package/es/components/viewer3d/fbm.js +414 -0
  147. package/es/components/viewer3d/front3D.js +66 -0
  148. package/es/components/viewer3d/grid-creator.js +25 -0
  149. package/es/components/viewer3d/grids/grid-horizontal-streak.js +36 -0
  150. package/es/components/viewer3d/grids/grid-streak.js +27 -0
  151. package/es/components/viewer3d/grids/grid-vertical-streak.js +36 -0
  152. package/es/components/viewer3d/libs/first-person-controls.js +67 -0
  153. package/es/components/viewer3d/libs/helvetiker_regular.typeface.js +1281 -0
  154. package/es/components/viewer3d/libs/mtl-loader.js +357 -0
  155. package/es/components/viewer3d/libs/obj-loader.js +462 -0
  156. package/es/components/viewer3d/libs/orbit-controls.js +699 -0
  157. package/es/components/viewer3d/libs/pointer-lock-controls.js +46 -0
  158. package/es/components/viewer3d/lrm.js +305 -0
  159. package/es/components/viewer3d/model.js +708 -0
  160. package/es/components/viewer3d/pointer-lock-navigation.js +115 -0
  161. package/es/components/viewer3d/ruler-utils/itemRect.js +61 -0
  162. package/es/components/viewer3d/ruler-utils/layer3D.js +495 -0
  163. package/es/components/viewer3d/ruler-utils/ruler3D.js +227 -0
  164. package/es/components/viewer3d/ruler-utils/scene3D.js +60 -0
  165. package/es/components/viewer3d/ruler-utils/state3D.js +18 -0
  166. package/es/components/viewer3d/scene-creator.js +3608 -0
  167. package/es/components/viewer3d/three-memory-cleaner.js +51 -0
  168. package/es/components/viewer3d/viewer3d-first-person.js +315 -0
  169. package/es/components/viewer3d/viewer3d.js +2527 -0
  170. package/es/constants.js +636 -0
  171. package/es/index.js +16 -0
  172. package/es/models.js +510 -0
  173. package/es/plugins/SVGLoader.js +1412 -0
  174. package/es/plugins/autosave.js +33 -0
  175. package/es/plugins/console-debugger.js +37 -0
  176. package/es/plugins/export.js +9 -0
  177. package/es/plugins/keyboard.js +101 -0
  178. package/es/reducers/areas-reducer.js +12 -0
  179. package/es/reducers/export.js +25 -0
  180. package/es/reducers/groups-reducer.js +38 -0
  181. package/es/reducers/holes-reducer.js +62 -0
  182. package/es/reducers/items-reducer.js +140 -0
  183. package/es/reducers/lines-reducer.js +45 -0
  184. package/es/reducers/project-reducer.js +129 -0
  185. package/es/reducers/reducer.js +19 -0
  186. package/es/reducers/scene-reducer.js +28 -0
  187. package/es/reducers/user-reducer.js +40 -0
  188. package/es/reducers/vertices-reducer.js +19 -0
  189. package/es/reducers/viewer2d-reducer.js +75 -0
  190. package/es/reducers/viewer3d-reducer.js +56 -0
  191. package/es/shared-style.js +66 -0
  192. package/es/styles/export.js +5 -0
  193. package/es/styles/tabs.css +40 -0
  194. package/es/translator/en.js +104 -0
  195. package/es/translator/it.js +79 -0
  196. package/es/translator/ru.js +79 -0
  197. package/es/translator/translator.js +84 -0
  198. package/es/utils/browser.js +33 -0
  199. package/es/utils/email-validator.js +4 -0
  200. package/es/utils/export.js +25 -0
  201. package/es/utils/geometry.js +2420 -0
  202. package/es/utils/get-edges-of-subgraphs.js +27 -0
  203. package/es/utils/graph-cycles.js +237 -0
  204. package/es/utils/graph-inner-cycles.js +46 -0
  205. package/es/utils/graph.js +150 -0
  206. package/es/utils/helper.js +268 -0
  207. package/es/utils/history.js +29 -0
  208. package/es/utils/id-broker.js +19 -0
  209. package/es/utils/logger.js +8 -0
  210. package/es/utils/math.js +50 -0
  211. package/es/utils/molding.js +871 -0
  212. package/es/utils/name-generator.js +18 -0
  213. package/es/utils/objects-utils.js +50 -0
  214. package/es/utils/phone-validator.js +4 -0
  215. package/es/utils/process-black-list.js +18 -0
  216. package/es/utils/react-if.js +18 -0
  217. package/es/utils/snap-scene.js +99 -0
  218. package/es/utils/snap.js +237 -0
  219. package/es/utils/summarizeCart.js +24 -0
  220. package/es/utils/threeCSG.es6.js +498 -0
  221. package/es/version.js +2 -0
  222. package/lib/catalog/properties/property-string.js +55 -0
  223. package/lib/catalog/properties/property-toggle.js +46 -0
  224. package/lib/catalog/properties/shared-property-style.js +20 -0
  225. package/lib/catalog/utils/FuseUtils.js +88 -0
  226. package/lib/catalog/utils/exporter.js +155 -0
  227. package/lib/catalog/utils/geom-utils.js +205 -0
  228. package/lib/catalog/utils/item-loader.js +1533 -0
  229. package/lib/catalog/utils/load-obj.js +99 -0
  230. package/lib/catalog/utils/mtl-loader.js +363 -0
  231. package/lib/catalog/utils/obj-loader.js +482 -0
  232. package/lib/class/FuseUtils.js +88 -0
  233. package/lib/class/area.js +150 -0
  234. package/lib/class/export.js +96 -0
  235. package/lib/class/group.js +445 -0
  236. package/lib/class/guide.js +67 -0
  237. package/lib/class/hole.js +934 -0
  238. package/lib/class/item.js +1889 -0
  239. package/lib/class/layer.js +672 -0
  240. package/lib/class/line.js +1186 -0
  241. package/lib/class/project.js +799 -0
  242. package/lib/class/vertex.js +207 -0
  243. package/lib/components/content.js +116 -0
  244. package/lib/components/disclaimer/disclaimer.js +105 -0
  245. package/lib/components/export.js +33 -0
  246. package/lib/components/style/button.js +120 -0
  247. package/lib/components/style/cancel-button.js +29 -0
  248. package/lib/components/style/content-container.js +40 -0
  249. package/lib/components/style/content-title.js +37 -0
  250. package/lib/components/style/delete-button.js +34 -0
  251. package/lib/components/style/export.js +121 -0
  252. package/lib/components/style/form-block.js +31 -0
  253. package/lib/components/style/form-color-input.js +34 -0
  254. package/lib/components/style/form-label.js +33 -0
  255. package/lib/components/style/form-number-input.js +220 -0
  256. package/lib/components/style/form-number-input_2.js +213 -0
  257. package/lib/components/style/form-select.js +75 -0
  258. package/lib/components/style/form-slider.js +68 -0
  259. package/lib/components/style/form-submit-button.js +35 -0
  260. package/lib/components/style/form-text-input.js +101 -0
  261. package/lib/components/viewer2d/area.js +88 -0
  262. package/lib/components/viewer2d/export.js +121 -0
  263. package/lib/components/viewer2d/grids/grid-horizontal-streak.js +44 -0
  264. package/lib/components/viewer2d/grids/grid-streak.js +44 -0
  265. package/lib/components/viewer2d/grids/grid-vertical-streak.js +44 -0
  266. package/lib/components/viewer2d/grids/grids.js +44 -0
  267. package/lib/components/viewer2d/group.js +62 -0
  268. package/lib/components/viewer2d/item.js +521 -0
  269. package/lib/components/viewer2d/layer.js +171 -0
  270. package/lib/components/viewer2d/line.js +892 -0
  271. package/lib/components/viewer2d/ruler.js +107 -0
  272. package/lib/components/viewer2d/rulerDist.js +153 -0
  273. package/lib/components/viewer2d/rulerX.js +158 -0
  274. package/lib/components/viewer2d/rulerY.js +160 -0
  275. package/lib/components/viewer2d/scene.js +147 -0
  276. package/lib/components/viewer2d/snap.js +83 -0
  277. package/lib/components/viewer2d/state.js +87 -0
  278. package/lib/components/viewer2d/utils.js +210 -0
  279. package/lib/components/viewer2d/vertex.js +74 -0
  280. package/lib/components/viewer2d/viewer2d.js +1405 -0
  281. package/lib/components/viewer3d/camera-controls-module/camera-controls.module.js +2597 -0
  282. package/lib/components/viewer3d/dcm.js +407 -0
  283. package/lib/components/viewer3d/fbm.js +420 -0
  284. package/lib/components/viewer3d/front3D.js +75 -0
  285. package/lib/components/viewer3d/grid-creator.js +34 -0
  286. package/lib/components/viewer3d/grids/grid-horizontal-streak.js +44 -0
  287. package/lib/components/viewer3d/grids/grid-streak.js +35 -0
  288. package/lib/components/viewer3d/grids/grid-vertical-streak.js +44 -0
  289. package/lib/components/viewer3d/libs/first-person-controls.js +74 -0
  290. package/lib/components/viewer3d/libs/helvetiker_regular.typeface.js +1287 -0
  291. package/lib/components/viewer3d/libs/mtl-loader.js +363 -0
  292. package/lib/components/viewer3d/libs/obj-loader.js +468 -0
  293. package/lib/components/viewer3d/libs/orbit-controls.js +705 -0
  294. package/lib/components/viewer3d/libs/pointer-lock-controls.js +52 -0
  295. package/lib/components/viewer3d/lrm.js +311 -0
  296. package/lib/components/viewer3d/model.js +714 -0
  297. package/lib/components/viewer3d/pointer-lock-navigation.js +122 -0
  298. package/lib/components/viewer3d/ruler-utils/itemRect.js +68 -0
  299. package/lib/components/viewer3d/ruler-utils/layer3D.js +502 -0
  300. package/lib/components/viewer3d/ruler-utils/ruler3D.js +234 -0
  301. package/lib/components/viewer3d/ruler-utils/scene3D.js +68 -0
  302. package/lib/components/viewer3d/ruler-utils/state3D.js +25 -0
  303. package/lib/components/viewer3d/scene-creator.js +3642 -0
  304. package/lib/components/viewer3d/three-memory-cleaner.js +60 -0
  305. package/lib/components/viewer3d/viewer3d-first-person.js +320 -0
  306. package/lib/components/viewer3d/viewer3d.js +2532 -0
  307. package/lib/constants.js +645 -0
  308. package/lib/index.js +96 -0
  309. package/lib/models.js +517 -0
  310. package/lib/plugins/SVGLoader.js +1417 -0
  311. package/lib/plugins/autosave.js +39 -0
  312. package/lib/plugins/console-debugger.js +44 -0
  313. package/lib/plugins/export.js +33 -0
  314. package/lib/plugins/keyboard.js +107 -0
  315. package/lib/reducers/areas-reducer.js +18 -0
  316. package/lib/reducers/export.js +97 -0
  317. package/lib/reducers/groups-reducer.js +44 -0
  318. package/lib/reducers/holes-reducer.js +68 -0
  319. package/lib/reducers/items-reducer.js +146 -0
  320. package/lib/reducers/lines-reducer.js +51 -0
  321. package/lib/reducers/project-reducer.js +135 -0
  322. package/lib/reducers/reducer.js +26 -0
  323. package/lib/reducers/scene-reducer.js +34 -0
  324. package/lib/reducers/user-reducer.js +46 -0
  325. package/lib/reducers/vertices-reducer.js +25 -0
  326. package/lib/reducers/viewer2d-reducer.js +82 -0
  327. package/lib/reducers/viewer3d-reducer.js +63 -0
  328. package/lib/shared-style.js +72 -0
  329. package/lib/styles/export.js +13 -0
  330. package/lib/translator/en.js +110 -0
  331. package/lib/translator/it.js +85 -0
  332. package/lib/translator/ru.js +85 -0
  333. package/lib/translator/translator.js +90 -0
  334. package/lib/utils/browser.js +40 -0
  335. package/lib/utils/email-validator.js +10 -0
  336. package/lib/utils/export.js +56 -0
  337. package/lib/utils/geometry.js +2516 -0
  338. package/lib/utils/get-edges-of-subgraphs.js +34 -0
  339. package/lib/utils/graph-cycles.js +240 -0
  340. package/lib/utils/graph-inner-cycles.js +54 -0
  341. package/lib/utils/graph.js +157 -0
  342. package/lib/utils/helper.js +291 -0
  343. package/lib/utils/history.js +36 -0
  344. package/lib/utils/id-broker.js +25 -0
  345. package/lib/utils/logger.js +14 -0
  346. package/lib/utils/math.js +57 -0
  347. package/lib/utils/molding.js +895 -0
  348. package/lib/utils/name-generator.js +23 -0
  349. package/lib/utils/objects-utils.js +60 -0
  350. package/lib/utils/phone-validator.js +10 -0
  351. package/lib/utils/process-black-list.js +24 -0
  352. package/lib/utils/react-if.js +24 -0
  353. package/lib/utils/snap-scene.js +105 -0
  354. package/lib/utils/snap.js +249 -0
  355. package/lib/utils/summarizeCart.js +30 -0
  356. package/lib/utils/threeCSG.es6.js +503 -0
  357. package/lib/version.js +8 -0
  358. package/package.json +3 -3
@@ -0,0 +1,895 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.createMonldingGroup = createMonldingGroup;
8
+ exports.getAllMoldingGroups = getAllMoldingGroups;
9
+ exports.getItemGroupFromMolding = getItemGroupFromMolding;
10
+ exports.getItemRect = getItemRect;
11
+ exports.getLinesFromItems = getLinesFromItems;
12
+ exports.getLinesFromItems2 = getLinesFromItems2;
13
+ exports.getLinesOfItem = getLinesOfItem;
14
+ exports.hasMoldingLayout = hasMoldingLayout;
15
+ exports.isEnableItemForMolding = isEnableItemForMolding;
16
+ exports.isItemSameItemByLocation = isItemSameItemByLocation;
17
+ exports.isItemSnappedGroup = isItemSnappedGroup;
18
+ exports.isItemSnappedItem = isItemSnappedItem;
19
+ exports.isLinesOverlapped = isLinesOverlapped;
20
+ exports.isSameMoldingLayoutpos = isSameMoldingLayoutpos;
21
+ exports.mergeOverlappedLines = mergeOverlappedLines;
22
+ exports.sortItemsByDistance = sortItemsByDistance;
23
+ exports.tryMergeMDItem = tryMergeMDItem;
24
+ var _constants = require("../constants");
25
+ var Three = _interopRequireWildcard(require("three"));
26
+ var _convertUnits = _interopRequireDefault(require("convert-units"));
27
+ var _idBroker = _interopRequireDefault(require("./id-broker"));
28
+ var _utils = require("../components/viewer2d/utils");
29
+ var _export = require("./export");
30
+ var _helper = require("./helper");
31
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
32
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
33
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
34
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
35
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
36
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
37
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
38
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
39
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
40
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
41
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
42
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
43
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
44
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
45
+ function getItemRect(item) {
46
+ var x = item.x;
47
+ var y = item.y;
48
+ var rotRad = item.rotation / 180 * Math.PI;
49
+ var itemWidth = item.properties.get('width').get('_length');
50
+ var itemWidthUnit = item.properties.get('width').get('_unit') || 'cm';
51
+ itemWidth = (0, _convertUnits["default"])(itemWidth / 2).from(itemWidthUnit).to('cm');
52
+ var itemDepth = item.properties.get('depth').get('_length');
53
+ var itemDepthUnit = item.properties.get('depth').get('_unit') || 'cm';
54
+ itemDepth = (0, _convertUnits["default"])(itemDepth / 2).from(itemDepthUnit).to('cm');
55
+ var mx = x - itemWidth * Math.cos(rotRad);
56
+ var my = y - itemWidth * Math.sin(rotRad);
57
+ var x0 = mx + itemDepth * Math.sin(rotRad);
58
+ var y0 = my - itemDepth * Math.cos(rotRad);
59
+ var x3 = mx * 2 - x0;
60
+ var y3 = my * 2 - y0;
61
+ var x1 = x * 2 - x3;
62
+ var y1 = y * 2 - y3;
63
+ var x2 = x * 2 - x0;
64
+ var y2 = y * 2 - y0;
65
+ return {
66
+ rect: [{
67
+ x: x0,
68
+ y: y0
69
+ }, {
70
+ x: x1,
71
+ y: y1
72
+ }, {
73
+ x: x2,
74
+ y: y2
75
+ }, {
76
+ x: x3,
77
+ y: y3
78
+ }]
79
+ };
80
+ }
81
+ function hasMoldingLayout(molding, layoutpos) {
82
+ var types = molding === null || molding === void 0 ? void 0 : molding.molding_type;
83
+ return (Array.isArray(types) || typeof types === 'string') && types.includes(layoutpos);
84
+ }
85
+ function isEnableItemForMolding(layer, selItem) {
86
+ var molding = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
87
+ var allLineRects = _export.GeometryUtils.buildRectFromLines(layer, _export.GeometryUtils.getAllLines(layer));
88
+ var result = !(0, _helper.isEmpty)(selItem) && selItem.category === 'cabinet' && (selItem.layoutpos === _constants.BASE_CABINET_LAYOUTPOS && !_export.GeometryUtils.isSnappedLine(getItemRect(selItem), allLineRects) || (selItem.layoutpos === _constants.WALL_CABINET_LAYOUTPOS || selItem.layoutpos === _constants.TALL_CABINET_LAYOUTPOS) && _export.GeometryUtils.isSnappedLine(getItemRect(selItem), allLineRects));
89
+
90
+ // check this item is enable for any molding
91
+ if ((0, _helper.isEmpty)(molding)) return result;
92
+ // check this item is enable for specified molding
93
+ else return result && hasMoldingLayout(molding, selItem.layoutpos);
94
+ }
95
+
96
+ /**
97
+ * Check two line segments are overlap. The direction of the two line segments must be opposite.
98
+ * s1 c2 s2 c1
99
+ * |--------|------|-----------|
100
+ * Decision Formular: L(s1,c1) + L(s2, c2) = L(s1, s2) + L(c1, c2)
101
+ * @param {*} selRectPos1
102
+ * @param {*} selRectPos2
103
+ * @param {*} curRectPos1
104
+ * @param {*} curRectPos2
105
+ * @returns L(s1,c1) + L(s2, c2) - L(s1, s2) - L(c1, c2)
106
+ */
107
+ function getDelta(selRectPos1, selRectPos2, curRectPos1, curRectPos2) {
108
+ return (
109
+ // GeometryUtils.verticesDistance(curRectPos1, selRectPos2) +
110
+ // GeometryUtils.verticesDistance(selRectPos1, curRectPos2) -
111
+ // Math.abs(
112
+ // GeometryUtils.verticesDistance(curRectPos2, curRectPos1) -
113
+ // GeometryUtils.verticesDistance(selRectPos1, selRectPos2)
114
+ // )
115
+ Math.abs(_export.GeometryUtils.verticesDistance(curRectPos1, selRectPos1) + _export.GeometryUtils.verticesDistance(selRectPos2, curRectPos2) - _export.GeometryUtils.verticesDistance(curRectPos2, curRectPos1) - _export.GeometryUtils.verticesDistance(selRectPos1, selRectPos2))
116
+ );
117
+ }
118
+ function isItemSnappedItem(selItem, curItem) {
119
+ var selRect = getItemRect(selItem).rect;
120
+ var curRect = getItemRect(curItem).rect;
121
+ var flag30 = getDelta(selRect[3], selRect[0], curRect[1], curRect[2]) < _constants.EPSILON;
122
+ var flag21 = getDelta(selRect[2], selRect[1], curRect[0], curRect[3]) < _constants.EPSILON;
123
+ var flag23 = getDelta(selRect[2], selRect[3], curRect[2], curRect[3]) < _constants.EPSILON;
124
+ var flag01 = getDelta(selRect[1], selRect[0], curRect[0], curRect[3]) < _constants.EPSILON;
125
+ var flag03 = getDelta(selRect[0], selRect[3], curRect[1], curRect[0]) < _constants.EPSILON;
126
+ return flag30 || flag21 || flag23 || flag01 || flag03;
127
+ }
128
+ function isItemSnappedGroup(selItem, itemGroup) {
129
+ return itemGroup.some(function (curItem) {
130
+ return isItemSnappedItem(selItem, curItem);
131
+ });
132
+ }
133
+ function sortItemsByDistance(items, selItem) {
134
+ items.sort(function (a, b) {
135
+ return _export.GeometryUtils.pointsDistance(a.x, a.y, selItem.x, selItem.y) - _export.GeometryUtils.pointsDistance(b.x, b.y, selItem.x, selItem.y);
136
+ });
137
+ return items;
138
+ }
139
+ function isSameMoldingLayoutpos(curItem, item) {
140
+ return curItem.layoutpos === _constants.BASE_CABINET_LAYOUTPOS && curItem.layoutpos === item.layoutpos || [_constants.WALL_CABINET_LAYOUTPOS, _constants.TALL_CABINET_LAYOUTPOS].includes(curItem.layoutpos) && [_constants.WALL_CABINET_LAYOUTPOS, _constants.TALL_CABINET_LAYOUTPOS].includes(item.layoutpos);
141
+ }
142
+ function isItemSameItemByLocation(item1, item2, location) {
143
+ var item1Altitude = item1.properties.get('altitude').get('_length');
144
+ var item1AltitudeUnit = item1.properties.get('altitude').get('_unit');
145
+ item1Altitude = (0, _convertUnits["default"])(item1Altitude).from(item1AltitudeUnit).to('cm');
146
+ var item1Height = item1.properties.get('height').get('_length');
147
+ var item1HeightUnit = item1.properties.get('height').get('_unit');
148
+ item1Height = (0, _convertUnits["default"])(item1Height).from(item1HeightUnit).to('cm');
149
+ var item2Altitude = item2.properties.get('altitude').get('_length');
150
+ var item2AltitudeUnit = item2.properties.get('altitude').get('_unit');
151
+ item2Altitude = (0, _convertUnits["default"])(item2Altitude).from(item2AltitudeUnit).to('cm');
152
+ var item2Height = item2.properties.get('height').get('_length');
153
+ var item2HeightUnit = item2.properties.get('height').get('_unit');
154
+ item2Height = (0, _convertUnits["default"])(item2Height).from(item2HeightUnit).to('cm');
155
+ var flag = false;
156
+ switch (location) {
157
+ case _constants.TOP_MOLDING_LOCATION:
158
+ if (_export.GeometryUtils.sameDistances(item1Altitude + item1Height, item2Altitude + item2Height)) flag = true;
159
+ break;
160
+ case _constants.MIDDLE_MOLDING_LOCATION:
161
+ if (_export.GeometryUtils.sameDistances(item1Altitude + item1Height / 2, item2Altitude + item2Height / 2)) flag = true;
162
+ break;
163
+ case _constants.BOTTOM_MOLDING_LOCATION:
164
+ if (_export.GeometryUtils.sameDistances(item1Altitude, item2Altitude)) flag = true;
165
+ break;
166
+ }
167
+ return flag;
168
+ }
169
+ function tryMergeMDItem(layer, selItem, curItem, itemGroup, molding) {
170
+ return isSameMoldingLayoutpos(selItem, curItem) && isEnableItemForMolding(layer, curItem, molding) && isItemSnappedGroup(curItem, itemGroup) && !itemGroup.some(function (item) {
171
+ return item.id === curItem.id;
172
+ }) && isItemSameItemByLocation(selItem, curItem, molding.location_type);
173
+ }
174
+ function getItemGroupFromMolding(layer, curItem, molding) {
175
+ var selectedItem = layer.getIn(['items', layer.selected.toJS().items[0]]);
176
+ var itemGroup = [curItem];
177
+ var temp_layer_items = layer.items.toArray().filter(function (item) {
178
+ return item.category === 'cabinet' && item.id !== curItem.id && item.id !== (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.id);
179
+ });
180
+ temp_layer_items = sortItemsByDistance(temp_layer_items, curItem);
181
+ for (var idx = 0; idx < temp_layer_items.length; idx++) {
182
+ if (tryMergeMDItem(layer, curItem, temp_layer_items[idx], itemGroup, molding)) {
183
+ itemGroup.push(temp_layer_items[idx]);
184
+ idx = -1;
185
+ }
186
+ }
187
+ return itemGroup;
188
+ }
189
+ function tryMergeItemWithLocation(curItem, itemGroup, location) {
190
+ return itemGroup.some(function (item) {
191
+ return isItemSnappedItem(curItem, item) && isItemSameItemByLocation(curItem, item, location);
192
+ });
193
+ }
194
+
195
+ /**
196
+ * Make the molding group array with [items].
197
+ * @param {*} layer
198
+ * @param {*} items - Mergable snapped item group, if [items] is null then get all MG array of layer
199
+ * @returns MG array
200
+ */
201
+ function getAllMoldingGroups(layer) {
202
+ var items = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
203
+ if (items === null) items = layer.items.toArray();
204
+ var MGArray = [];
205
+ items.forEach(function (curItem) {
206
+ // let allLineRects = GeometryUtils.buildRectFromLines(
207
+ // layer,
208
+ // GeometryUtils.getAllLines(layer)
209
+ // );
210
+ // if (
211
+ // (curItem.category === 'cabinet' &&
212
+ // curItem.layoutpos === BASE_CABINET_LAYOUTPOS &&
213
+ // !GeometryUtils.isSnappedLine(getItemRect(curItem), allLineRects)) ||
214
+ // ((curItem.layoutpos === WALL_CABINET_LAYOUTPOS ||
215
+ // curItem.layoutpos === TALL_CABINET_LAYOUTPOS) &&
216
+ // GeometryUtils.isSnappedLine(getItemRect(curItem), allLineRects))
217
+ // ) {
218
+ if (curItem.category === 'cabinet') {
219
+ var temp_items = items.filter(function (it) {
220
+ return it.category === 'cabinet' && isSameMoldingLayoutpos(curItem, it) && it.id !== curItem.id;
221
+ });
222
+ temp_items = sortItemsByDistance(temp_items, curItem);
223
+ _constants.MOLDING_LOCATIONS.forEach(function (location) {
224
+ if (!MGArray.some(function (mg) {
225
+ return mg.items.some(function (it) {
226
+ return it.id === curItem.id;
227
+ }) && mg.location_type === location;
228
+ })) {
229
+ var itemGroup = [curItem];
230
+ var isChangedItemGroup = false;
231
+ do {
232
+ isChangedItemGroup = false;
233
+ var _loop = function _loop(idx) {
234
+ if (!itemGroup.some(function (it) {
235
+ return it.id === temp_items[idx].id;
236
+ }) && tryMergeItemWithLocation(temp_items[idx], itemGroup, location)) {
237
+ itemGroup.push(temp_items[idx]);
238
+ isChangedItemGroup = true;
239
+ }
240
+ };
241
+ for (var idx = 0; idx < temp_items.length; idx++) {
242
+ _loop(idx);
243
+ }
244
+ } while (isChangedItemGroup);
245
+ MGArray.push({
246
+ id: _idBroker["default"].acquireID(),
247
+ items: itemGroup,
248
+ location_type: location,
249
+ molding: null,
250
+ lines: null,
251
+ pointGroups: null,
252
+ meshes: [],
253
+ rot: 0,
254
+ pos: 0
255
+ });
256
+ }
257
+ });
258
+ }
259
+ // }
260
+ });
261
+ return MGArray;
262
+ }
263
+ function getLinesOfItem(item, allLineRects, catalog) {
264
+ var lines = [];
265
+ var outline = null;
266
+ var element = catalog.elements[item.get('type')];
267
+ if (!element) element = catalog.elements[(0, _utils.returnReplaceableDeepSearchType)(item.get('type'))];
268
+ // get edge lines
269
+ var newWidth = item.properties.get('width').get('_length');
270
+ var wUnit = item.properties.get('width').get('_unit') || 'cm';
271
+ newWidth = (0, _convertUnits["default"])(newWidth).from(wUnit).to('cm');
272
+ var newDepth = item.properties.get('depth').get('_length');
273
+ var hUnit = item.properties.get('depth').get('_unit') || 'cm';
274
+ newDepth = (0, _convertUnits["default"])(newDepth).from(hUnit).to('cm');
275
+ if (item) {
276
+ // Get Outline Data of Selected Item
277
+ outline = element.info.outline;
278
+ if (outline) {
279
+ // Extract Points from `outline`
280
+ var outlinePaths = outline.paths;
281
+ var outlineWidth = outline.svgWidth;
282
+ var outlineHeight = outline.svgHeight;
283
+ var outlinePoints = []; // Hold Points Of SVG
284
+ var _iterator = _createForOfIteratorHelper(outlinePaths),
285
+ _step;
286
+ try {
287
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
288
+ var path = _step.value;
289
+ var _iterator2 = _createForOfIteratorHelper(path.subPaths),
290
+ _step2;
291
+ try {
292
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
293
+ var subPath = _step2.value;
294
+ outlinePoints = outlinePoints.concat(subPath.getPoints());
295
+ }
296
+ } catch (err) {
297
+ _iterator2.e(err);
298
+ } finally {
299
+ _iterator2.f();
300
+ }
301
+ }
302
+ } catch (err) {
303
+ _iterator.e(err);
304
+ } finally {
305
+ _iterator.f();
306
+ }
307
+ outline.reverse && outlinePoints.reverse();
308
+ for (var i = 0; i < outlinePoints.length - 1; i++) {
309
+ lines.push([_export.GeometryUtils.rotatePointAroundPoint((outlinePoints[i].x / outlineWidth - 0.5) * newWidth + item.x, (outlinePoints[i].y / outlineHeight - 0.5) * newDepth + item.y, item.x, item.y, item.rotation + 90), _export.GeometryUtils.rotatePointAroundPoint((outlinePoints[i + 1].x / outlineWidth - 0.5) * newWidth + item.x, (outlinePoints[i + 1].y / outlineHeight - 0.5) * newDepth + item.y, item.x, item.y, item.rotation + 90), _idBroker["default"].acquireID()]);
310
+ }
311
+ } else {
312
+ var pos = [[-1, -1], [1, -1], [1, 1], [-1, 1]];
313
+ for (var _i = 0; _i < 4; _i++) {
314
+ lines.push([_export.GeometryUtils.rotatePointAroundPoint(pos[_i][0] * newWidth / 2 + item.x, pos[_i][1] * newDepth / 2 + item.y, item.x, item.y, item.rotation), _export.GeometryUtils.rotatePointAroundPoint(pos[(_i + 1) % 4][0] * newWidth / 2 + item.x, pos[(_i + 1) % 4][1] * newDepth / 2 + item.y, item.x, item.y, item.rotation), _idBroker["default"].acquireID()]);
315
+ }
316
+ }
317
+ }
318
+ if (item.layoutpos !== _constants.BASE_CABINET_LAYOUTPOS) {
319
+ lines = lines.filter(function (line) {
320
+ return !_export.GeometryUtils.isSnappedLine({
321
+ rect: [{
322
+ x: 0,
323
+ y: 0
324
+ }, {
325
+ x: 0,
326
+ y: 0
327
+ }, line[0], line[1]]
328
+ }, allLineRects);
329
+ });
330
+ }
331
+ return lines;
332
+ }
333
+ function isParallelLines(line1, line2) {
334
+ var isParallel = false;
335
+ if (Math.abs(line1[0].y - line1[1].y) <= _constants.EPSILON && Math.abs(line2[0].y - line2[1].y) <= _constants.EPSILON) isParallel = true;
336
+ if (Math.abs(line1[0].x - line1[1].x) <= _constants.EPSILON && Math.abs(line2[0].x - line2[1].x) <= _constants.EPSILON) isParallel = true;
337
+ if (Math.abs((line1[0].x - line1[1].x) / (line1[0].y - line1[1].y) - (line2[0].x - line2[1].x) / (line2[0].y - line2[1].y)) <= _constants.EPSILON) isParallel = true;
338
+ if (isParallel) {
339
+ return true;
340
+ }
341
+ return false;
342
+ }
343
+ function isLinesOverlapped(line1, line2) {
344
+ return isParallelLines(line1, line2) && line1.some(function (l1) {
345
+ return line2.some(function (l2) {
346
+ return _export.GeometryUtils.samePoints(l1, l2);
347
+ });
348
+ });
349
+ }
350
+ function mergeOverlappedLines(line1, line2) {
351
+ var line1_idx = 0,
352
+ line2_idx = 0;
353
+ line1.forEach(function (l1, idx1) {
354
+ if (idx1 !== line1.length - 1) {
355
+ line2.forEach(function (l2, idx2) {
356
+ if (idx2 !== line2.length - 1) {
357
+ if (_export.GeometryUtils.samePoints(l1, l2)) {
358
+ line1_idx = idx1;
359
+ line2_idx = idx2;
360
+ }
361
+ }
362
+ });
363
+ }
364
+ });
365
+ //If line1 's end point and line2 's start point is same, two lines merge into a line with
366
+ //the line1's start point as the start point and line2's end point as the end point.
367
+ if (line1_idx === 1) {
368
+ return [line1[1 - line1_idx], line2[1 - line2_idx], _idBroker["default"].acquireID()];
369
+ } else {
370
+ return [line2[1 - line2_idx], line1[1 - line1_idx], _idBroker["default"].acquireID()];
371
+ }
372
+ }
373
+
374
+ /**
375
+ * Get the contour line array of moldingGroup items
376
+ * @param {*} moldingGroup
377
+ * @param {*} layer
378
+ * @param {*} catalog
379
+ * @returns contour line array of moldingGroup items
380
+ */
381
+ function getLinesFromItems2(moldingGroup, layer, catalog) {
382
+ // wall lines
383
+ var allLineRects = _export.GeometryUtils.buildRectFromLines(layer, _export.GeometryUtils.getAllLines(layer));
384
+ var MGlines = [];
385
+ var MGlinesOtherSnapped = [];
386
+ var items = _toConsumableArray(moldingGroup.items);
387
+ // The other item's lines (these items are snapped to the moldingGroup items)
388
+ var itemsOtherSnapped = layer.items.toArray().filter(function (item) {
389
+ if (items.some(function (it) {
390
+ return item.id === it.id;
391
+ })) return false;
392
+ if (isItemSnappedGroup(item, items)) {
393
+ var itemLines = getLinesOfItem(item, allLineRects, catalog);
394
+ var itemAltitude = item.properties.get('altitude').get('_length');
395
+ var itemAltitudeUnit = item.properties.get('altitude').get('_unit');
396
+ itemAltitude = (0, _convertUnits["default"])(itemAltitude).from(itemAltitudeUnit).to('cm');
397
+ var itemHeight = item.properties.get('height').get('_length');
398
+ var itemHeightUnit = item.properties.get('height').get('_unit');
399
+ itemHeight = (0, _convertUnits["default"])(itemHeight).from(itemHeightUnit).to('cm');
400
+ itemLines.forEach(function (line) {
401
+ line.push({
402
+ altitude: itemAltitude,
403
+ height: itemHeight
404
+ });
405
+ });
406
+ MGlinesOtherSnapped = [].concat(_toConsumableArray(MGlinesOtherSnapped), _toConsumableArray(itemLines));
407
+ return true;
408
+ } else return false;
409
+ });
410
+
411
+ // get all lines of moldingGroup items
412
+ items.forEach(function (item) {
413
+ var itemAltitude = item.properties.get('altitude').get('_length');
414
+ var itemAltitudeUnit = item.properties.get('altitude').get('_unit');
415
+ itemAltitude = (0, _convertUnits["default"])(itemAltitude).from(itemAltitudeUnit).to('cm');
416
+ var itemHeight = item.properties.get('height').get('_length');
417
+ var itemHeightUnit = item.properties.get('height').get('_unit');
418
+ itemHeight = (0, _convertUnits["default"])(itemHeight).from(itemHeightUnit).to('cm');
419
+ var itemLines = getLinesOfItem(item, allLineRects, catalog);
420
+
421
+ // remove the edge that overlapped with other snapped items
422
+ itemLines = itemLines.filter(function (itLine) {
423
+ var ret = true;
424
+ var srcLine = {
425
+ x1: itLine[0].x,
426
+ y1: itLine[0].y,
427
+ x2: itLine[1].x,
428
+ y2: itLine[1].y
429
+ };
430
+ for (var j = 0; j < MGlinesOtherSnapped.length; j++) {
431
+ var bCheck = false;
432
+ switch (moldingGroup.location_type) {
433
+ case _constants.TOP_MOLDING_LOCATION:
434
+ bCheck = MGlinesOtherSnapped[j][3].altitude + MGlinesOtherSnapped[j][3].height > itemAltitude + itemHeight;
435
+ break;
436
+ case _constants.MIDDLE_MOLDING_LOCATION:
437
+ bCheck = true;
438
+ break;
439
+ case _constants.BOTTOM_MOLDING_LOCATION:
440
+ bCheck = MGlinesOtherSnapped[j][3].altitude < itemAltitude;
441
+ break;
442
+ }
443
+ if (item.category !== 'cabinet' || ![_constants.BASE_CABINET_LAYOUTPOS, _constants.WALL_CABINET_LAYOUTPOS, _constants.TALL_CABINET_LAYOUTPOS].includes(item.layoutpos)) bCheck = true;
444
+ if (bCheck) {
445
+ var destLine = {
446
+ x1: MGlinesOtherSnapped[j][0].x,
447
+ y1: MGlinesOtherSnapped[j][0].y,
448
+ x2: MGlinesOtherSnapped[j][1].x,
449
+ y2: MGlinesOtherSnapped[j][1].y
450
+ };
451
+ var rst = _export.GeometryUtils.relationshipOfTwoOverlappedLines(srcLine, destLine);
452
+ if (rst.result === _constants.OVERLAP_SAME || rst.result === _constants.OVERLAP_INCLUDED) {
453
+ ret = false;
454
+ break;
455
+ }
456
+ }
457
+ }
458
+ return ret;
459
+ });
460
+ MGlines = [].concat(_toConsumableArray(MGlines), _toConsumableArray(itemLines));
461
+ });
462
+
463
+ // Filtering overlapped edges and get contour edges
464
+ var removeLineIds = []; // remove the edge that fully overlapped to other edge
465
+ var newLines = []; // new countour edge segment that except the overlapped part
466
+ var _loop2 = function _loop2(i) {
467
+ var srcLine = {
468
+ x1: MGlines[i][0].x,
469
+ y1: MGlines[i][0].y,
470
+ x2: MGlines[i][1].x,
471
+ y2: MGlines[i][1].y
472
+ };
473
+ var _loop4 = function _loop4(j) {
474
+ if (i === j) return 0; // continue
475
+ var destLine = {
476
+ x1: MGlines[j][0].x,
477
+ y1: MGlines[j][0].y,
478
+ x2: MGlines[j][1].x,
479
+ y2: MGlines[j][1].y
480
+ };
481
+ var rst = _export.GeometryUtils.relationshipOfTwoOverlappedLines(srcLine, destLine);
482
+ if (rst.result === _constants.OVERLAP_SAME || rst.result === _constants.OVERLAP_INCLUDED) {
483
+ removeLineIds.push(i);
484
+ return 1; // break
485
+ } else if (rst.result === _constants.OVERLAP_SOME) {
486
+ removeLineIds.push(i);
487
+ var lineSegs = getTrimmedContourLineSegs(rst.trimmedSegs, MGlines.filter(function (v, idx) {
488
+ return idx !== i && idx !== j;
489
+ }), 0);
490
+ if (lineSegs.length > 0) newLines = [].concat(_toConsumableArray(newLines), _toConsumableArray(lineSegs));
491
+ return 1; // break
492
+ }
493
+ },
494
+ _ret2;
495
+ for (var j = 0; j < MGlines.length; j++) {
496
+ _ret2 = _loop4(j);
497
+ if (_ret2 === 0) continue;
498
+ if (_ret2 === 1) break;
499
+ }
500
+ };
501
+ for (var i = 0; i < MGlines.length; i++) {
502
+ _loop2(i);
503
+ }
504
+ MGlines = MGlines.filter(function (line, idx) {
505
+ return !removeLineIds.some(function (id) {
506
+ return idx === id;
507
+ });
508
+ });
509
+ if (newLines.length > 0) MGlines = [].concat(_toConsumableArray(MGlines), _toConsumableArray(newLines));
510
+
511
+ // merge the collinear linked lines to one line
512
+ var newMGlines = [];
513
+ var filteredMGlines = MGlines;
514
+ var _loop3 = function _loop3(_i2) {
515
+ if (filteredMGlines.length < 1) return 0; // break
516
+ if (!filteredMGlines.some(function (v) {
517
+ return v[2] === MGlines[_i2][2];
518
+ })) return 1; // continue
519
+ var mergedResult = getMergedLine(MGlines[_i2], filteredMGlines, 0);
520
+ if (mergedResult) {
521
+ newMGlines.push(mergedResult.mergedLine);
522
+ filteredMGlines = mergedResult.filteredMGlines;
523
+ }
524
+ },
525
+ _ret;
526
+ for (var _i2 = 0; _i2 < MGlines.length; _i2++) {
527
+ _ret = _loop3(_i2);
528
+ if (_ret === 0) break;
529
+ if (_ret === 1) continue;
530
+ }
531
+ return newMGlines;
532
+ }
533
+
534
+ /**
535
+ * Get the line that colinear linked with [line], and merge them to a new line
536
+ * @param {*} line
537
+ * @param {*} MGlines
538
+ * @returns
539
+ * - returns merged new line
540
+ * - returns filtered new line group (remove linked line from [MGlines])
541
+ */
542
+ function getMergedLine(line, MGlines, cnt) {
543
+ try {
544
+ cnt++;
545
+ if (cnt > 5000) {
546
+ console.log('getMergedLine has limited!');
547
+ return null;
548
+ }
549
+ var newMGlines = MGlines.filter(function (v) {
550
+ return line[2] !== v[2];
551
+ });
552
+ var mergeResult = {
553
+ mergedLine: line,
554
+ filteredMGlines: newMGlines
555
+ };
556
+ var srcLine = {
557
+ x1: line[0].x,
558
+ y1: line[0].y,
559
+ x2: line[1].x,
560
+ y2: line[1].y
561
+ };
562
+ var _loop5 = function _loop5(i) {
563
+ var destLine = {
564
+ x1: newMGlines[i][0].x,
565
+ y1: newMGlines[i][0].y,
566
+ x2: newMGlines[i][1].x,
567
+ y2: newMGlines[i][1].y
568
+ };
569
+ var rst = _export.GeometryUtils.relationshipOfTwoOverlappedLines(srcLine, destLine);
570
+ if (rst.result === _constants.OVERLAP_LINK) {
571
+ var mergedLine = [{
572
+ x: rst.linkedLine.x1,
573
+ y: rst.linkedLine.y1
574
+ }, {
575
+ x: rst.linkedLine.x2,
576
+ y: rst.linkedLine.y2
577
+ }, _idBroker["default"].acquireID()];
578
+ mergeResult = getMergedLine(mergedLine, newMGlines.filter(function (v, idx) {
579
+ return idx !== i;
580
+ }), cnt);
581
+ }
582
+ };
583
+ for (var i = 0; i < newMGlines.length; i++) {
584
+ _loop5(i);
585
+ }
586
+ return mergeResult;
587
+ } catch (e) {
588
+ console.log('getMergedLine catched :', e);
589
+ return null;
590
+ }
591
+ }
592
+
593
+ /**
594
+ * Get the contour line segments from [lineSegs]
595
+ * @param {*} lineSegs
596
+ * @param {*} otherLines
597
+ * @returns
598
+ */
599
+ function getTrimmedContourLineSegs(lineSegs, otherLines, cnt) {
600
+ try {
601
+ cnt++;
602
+ if (cnt > 5000) {
603
+ console.log('getTrimmedContourLineSegs has limited!');
604
+ return [];
605
+ }
606
+ var returnSegs = [];
607
+ for (var i = 0; i < lineSegs.length; i++) {
608
+ var srcLine = {
609
+ x1: lineSegs[i].x1,
610
+ y1: lineSegs[i].y1,
611
+ x2: lineSegs[i].x2,
612
+ y2: lineSegs[i].y2
613
+ };
614
+ var bContourSeg = true;
615
+ var _loop6 = function _loop6(j) {
616
+ var destLine = {
617
+ x1: otherLines[j][0].x,
618
+ y1: otherLines[j][0].y,
619
+ x2: otherLines[j][1].x,
620
+ y2: otherLines[j][1].y
621
+ };
622
+ var rst = _export.GeometryUtils.relationshipOfTwoOverlappedLines(srcLine, destLine);
623
+ if (rst.result == _constants.OVERLAP_SAME || rst.result == _constants.OVERLAP_INCLUDED) {
624
+ bContourSeg = false;
625
+ return 0; // break
626
+ } else if (rst.result == _constants.OVERLAP_SOME) {
627
+ var tLineSegs = getTrimmedContourLineSegs(rst.trimmedSegs, otherLines.filter(function (v, idx) {
628
+ return idx !== j;
629
+ }), cnt);
630
+ if (tLineSegs.length > 0) returnSegs = [].concat(_toConsumableArray(returnSegs), _toConsumableArray(tLineSegs));
631
+ bContourSeg = false;
632
+ return 0; // break
633
+ }
634
+ },
635
+ _ret3;
636
+ for (var j = 0; j < otherLines.length; j++) {
637
+ _ret3 = _loop6(j);
638
+ if (_ret3 === 0) break;
639
+ }
640
+ if (bContourSeg) returnSegs.push([{
641
+ x: lineSegs[i].x1,
642
+ y: lineSegs[i].y1
643
+ }, {
644
+ x: lineSegs[i].x2,
645
+ y: lineSegs[i].y2
646
+ }, _idBroker["default"].acquireID()]);
647
+ }
648
+ return returnSegs;
649
+ } catch (e) {
650
+ console.log('getTrimmedContourLineSegs catched :', e);
651
+ return [];
652
+ }
653
+ }
654
+ function getLinesFromItems(moldingGroup, layer, catalog) {
655
+ var allLineRects = _export.GeometryUtils.buildRectFromLines(layer, _export.GeometryUtils.getAllLines(layer));
656
+ var items = _toConsumableArray(moldingGroup.items);
657
+ var MGlines = getLinesOfItem(items[0], allLineRects, catalog);
658
+ items = sortItemsByDistance(items, items[0]);
659
+ var _loop7 = function _loop7() {
660
+ var itemLines = getLinesOfItem(items[i], allLineRects, catalog);
661
+ var temp_MGLines = [];
662
+ MGlines.forEach(function (line) {
663
+ var idx = itemLines.findIndex(function (itemLine) {
664
+ return isLinesOverlapped(line, itemLine);
665
+ });
666
+ var curItemLine = itemLines[idx];
667
+ if (idx > -1) {
668
+ if (!(_export.GeometryUtils.samePoints(line[0], curItemLine[0]) && _export.GeometryUtils.samePoints(line[1], curItemLine[1]) || _export.GeometryUtils.samePoints(line[0], curItemLine[1]) && _export.GeometryUtils.samePoints(line[1], curItemLine[0]))) {
669
+ var MGLine = mergeOverlappedLines(line, curItemLine);
670
+ temp_MGLines.push(MGLine);
671
+ }
672
+ itemLines.splice(idx, 1);
673
+ } else {
674
+ temp_MGLines.push(line);
675
+ }
676
+ });
677
+ itemLines.forEach(function (itemLine) {
678
+ return temp_MGLines.push(itemLine);
679
+ });
680
+ MGlines = [].concat(temp_MGLines);
681
+ };
682
+ for (var i = 1; i < items.length; i++) {
683
+ _loop7();
684
+ }
685
+ // return MGlines;
686
+ var snapped_other_items = layer.items.toArray().filter(function (item) {
687
+ if (items.some(function (it) {
688
+ return item.id === it.id;
689
+ })) return false;
690
+ return isItemSnappedGroup(item, items);
691
+ });
692
+ snapped_other_items.forEach(function (item) {
693
+ var itemAltitude = item.properties.get('altitude').get('_length');
694
+ var itemAltitudeUnit = item.properties.get('altitude').get('_unit');
695
+ itemAltitude = (0, _convertUnits["default"])(itemAltitude).from(itemAltitudeUnit).to('cm');
696
+ var itemHeight = item.properties.get('height').get('_length');
697
+ var itemHeightUnit = item.properties.get('height').get('_unit');
698
+ itemHeight = (0, _convertUnits["default"])(itemHeight).from(itemHeightUnit).to('cm');
699
+ var mgroupAltitude = items[0].properties.get('altitude').get('_length');
700
+ var mgroupAltitudeUnit = items[0].properties.get('altitude').get('_unit');
701
+ mgroupAltitude = (0, _convertUnits["default"])(mgroupAltitude).from(mgroupAltitudeUnit).to('cm');
702
+ var mgroupHeight = items[0].properties.get('height').get('_length');
703
+ var mgroupHeightUnit = items[0].properties.get('height').get('_unit');
704
+ mgroupHeight = (0, _convertUnits["default"])(mgroupHeight).from(mgroupHeightUnit).to('cm');
705
+ var flag = false;
706
+ switch (moldingGroup.location_type) {
707
+ case _constants.TOP_MOLDING_LOCATION:
708
+ flag = itemAltitude + itemHeight > mgroupAltitude + mgroupHeight;
709
+ break;
710
+ case _constants.MIDDLE_MOLDING_LOCATION:
711
+ flag = true;
712
+ break;
713
+ case _constants.BOTTOM_MOLDING_LOCATION:
714
+ flag = itemAltitude < mgroupAltitude;
715
+ break;
716
+ }
717
+ if (item.category !== 'cabinet' || ![_constants.BASE_CABINET_LAYOUTPOS, _constants.WALL_CABINET_LAYOUTPOS, _constants.TALL_CABINET_LAYOUTPOS].includes(item.layoutpos)) flag = true;
718
+ if (flag) {
719
+ var itemLines = getLinesOfItem(item, allLineRects, catalog);
720
+ var temp_MGLines = [];
721
+ MGlines.forEach(function (mgl) {
722
+ var idx = itemLines.findIndex(function (itl) {
723
+ return isLinesOverlapped(mgl, itl);
724
+ });
725
+ var curITL = itemLines[idx];
726
+ if (idx > -1) {
727
+ if (getDelta(mgl[0], mgl[1], curITL[1], curITL[0]) < _constants.EPSILON || getDelta(mgl[0], mgl[1], curITL[0], curITL[1]) < _constants.EPSILON) {
728
+ if (_export.GeometryUtils.verticesDistance(mgl[0], mgl[1]) > _export.GeometryUtils.verticesDistance(curITL[0], curITL[1])) {
729
+ var MGLine = mergeOverlappedLines(mgl, curITL);
730
+ temp_MGLines.push(MGLine);
731
+ }
732
+ itemLines.splice(idx, 1);
733
+ } else {
734
+ temp_MGLines.push(mgl);
735
+ }
736
+ } else {
737
+ temp_MGLines.push(mgl);
738
+ }
739
+ });
740
+ MGlines = [].concat(temp_MGLines);
741
+ }
742
+ });
743
+ return MGlines;
744
+ }
745
+ function getMDPoints(newMD) {
746
+ if (newMD.lines.length < 1) return _objectSpread(_objectSpread({}, newMD), {}, {
747
+ pointGroups: []
748
+ });
749
+ // let maxX = newMD.lines[0][0].x,
750
+ var maxX = newMD.lines[0][0].x,
751
+ minX = newMD.lines[0][0].x;
752
+ var maxY = newMD.lines[0][0].y,
753
+ minY = newMD.lines[0][0].y;
754
+ newMD.lines.forEach(function (line) {
755
+ if (line[0].x > maxX) {
756
+ maxX = line[0].x;
757
+ }
758
+ if (line[0].x < minX) {
759
+ minX = line[0].x;
760
+ }
761
+ if (line[1].x > maxX) {
762
+ maxX = line[1].x;
763
+ }
764
+ if (line[1].x < minX) {
765
+ minX = line[1].x;
766
+ }
767
+ if (line[0].y > maxY) {
768
+ maxY = line[0].y;
769
+ }
770
+ if (line[0].y < minY) {
771
+ minY = line[0].y;
772
+ }
773
+ if (line[1].y > maxY) {
774
+ maxY = line[1].y;
775
+ }
776
+ if (line[1].y < minY) {
777
+ minY = line[1].y;
778
+ }
779
+ });
780
+ var cPos = {
781
+ x: (maxX + minX) / 2,
782
+ y: (maxY + minY) / 2
783
+ };
784
+ var newSize = _objectSpread(_objectSpread({}, newMD.size), {}, {
785
+ width: maxX - minX,
786
+ depth: maxY - minY
787
+ });
788
+
789
+ // get vertex points
790
+ var MDlines = _toConsumableArray(newMD.lines);
791
+ var pointGroups = [[]];
792
+ var flag = 1;
793
+ var i = 0;
794
+ var _loop8 = function _loop8() {
795
+ if (pointGroups[i].length === 0) {
796
+ pointGroups[i].push(new Three.Vector2(MDlines[0][0].x - cPos.x, MDlines[0][0].y - cPos.y), new Three.Vector2(MDlines[0][1].x - cPos.x, MDlines[0][1].y - cPos.y));
797
+ MDlines.splice(0, 1);
798
+ } else {
799
+ if (flag) {
800
+ var lastPoint = pointGroups[i][pointGroups[i].length - 1];
801
+ var res = MDlines.findIndex(function (a) {
802
+ return _export.GeometryUtils.samePoints({
803
+ x: a[0].x - cPos.x,
804
+ y: a[0].y - cPos.y
805
+ }, lastPoint) || _export.GeometryUtils.samePoints({
806
+ x: a[1].x - cPos.x,
807
+ y: a[1].y - cPos.y
808
+ }, lastPoint);
809
+ });
810
+ if (res > -1) {
811
+ var newPos = {
812
+ x: MDlines[res][0].x - cPos.x,
813
+ y: MDlines[res][0].y - cPos.y
814
+ };
815
+ if (_export.GeometryUtils.samePoints(newPos, lastPoint)) {
816
+ newPos = {
817
+ x: MDlines[res][1].x - cPos.x,
818
+ y: MDlines[res][1].y - cPos.y
819
+ };
820
+ }
821
+ pointGroups[i].push(new Three.Vector2(newPos.x, newPos.y));
822
+ MDlines.splice(res, 1);
823
+ } else {
824
+ flag = 0;
825
+ }
826
+ } else {
827
+ var firstPoint = pointGroups[i][0];
828
+ var _res = MDlines.findIndex(function (a) {
829
+ return _export.GeometryUtils.samePoints({
830
+ x: a[0].x - cPos.x,
831
+ y: a[0].y - cPos.y
832
+ }, firstPoint) || _export.GeometryUtils.samePoints({
833
+ x: a[1].x - cPos.x,
834
+ y: a[1].y - cPos.y
835
+ }, firstPoint);
836
+ });
837
+ if (_res > -1) {
838
+ var _newPos = {
839
+ x: MDlines[_res][0].x - cPos.x,
840
+ y: MDlines[_res][0].y - cPos.y
841
+ };
842
+ if (_export.GeometryUtils.samePoints(_newPos, firstPoint)) {
843
+ _newPos = {
844
+ x: MDlines[_res][1].x - cPos.x,
845
+ y: MDlines[_res][1].y - cPos.y
846
+ };
847
+ }
848
+ pointGroups[i] = [new Three.Vector2(_newPos.x, _newPos.y)].concat(_toConsumableArray(pointGroups[i]));
849
+ MDlines.splice(_res, 1);
850
+ } else {
851
+ flag = 1;
852
+ i++;
853
+ if (MDlines.length !== 0) pointGroups.push([]);
854
+ }
855
+ }
856
+ }
857
+ };
858
+ while (MDlines.length !== 0) {
859
+ _loop8();
860
+ }
861
+ var z = newMD.items[0].properties.get('altitude').get('_length');
862
+ var zUnit = newMD.items[0].properties.get('altitude').get('_unit') || 'cm';
863
+ z = (0, _convertUnits["default"])(z).from(zUnit).to('cm');
864
+ var height = newMD.items[0].properties.get('height').get('_length');
865
+ var heightUnit = newMD.items[0].properties.get('height').get('_unit') || 'cm';
866
+ height = (0, _convertUnits["default"])(height).from(heightUnit).to('cm');
867
+ switch (newMD.location_type) {
868
+ case _constants.TOP_MOLDING_LOCATION:
869
+ z += height;
870
+ break;
871
+ case _constants.MIDDLE_MOLDING_LOCATION:
872
+ z += height / 2;
873
+ break;
874
+ case _constants.BOTTOM_MOLDING_LOCATION:
875
+ z += 0;
876
+ break;
877
+ default:
878
+ break;
879
+ }
880
+ return _objectSpread(_objectSpread({}, newMD), {}, {
881
+ pointGroups: pointGroups,
882
+ pos: _objectSpread(_objectSpread({}, cPos), {}, {
883
+ z: z
884
+ }),
885
+ size: newSize
886
+ });
887
+ }
888
+ function createMonldingGroup(oldMG, layer, molding, catalog) {
889
+ var newMG = _objectSpread({}, oldMG);
890
+ newMG.molding = molding;
891
+ newMG.lines = getLinesFromItems2(oldMG, layer, catalog);
892
+ newMG.lines.reverse();
893
+ newMG = getMDPoints(newMG);
894
+ return newMG;
895
+ }