kitchen-simulator 1.1.1-test.72 → 1.1.1-test.74
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.
- package/es/@history.js +2 -5
- package/es/AppContext.js +3 -6
- package/es/KitchenConfigurator.js +86 -86
- package/es/KitchenConfiguratorApp.js +134 -128
- package/es/actions/area-actions.js +5 -8
- package/es/actions/export.js +12 -24
- package/es/actions/groups-actions.js +27 -41
- package/es/actions/holes-actions.js +34 -51
- package/es/actions/items-actions.js +94 -141
- package/es/actions/lines-actions.js +21 -32
- package/es/actions/project-actions.js +94 -141
- package/es/actions/scene-actions.js +11 -17
- package/es/actions/vertices-actions.js +7 -11
- package/es/actions/viewer2d-actions.js +21 -32
- package/es/actions/viewer3d-actions.js +9 -14
- package/es/catalog/areas/area/planner-element.js +2 -5
- package/es/catalog/catalog.js +15 -17
- package/es/catalog/factories/area-factory-3d.js +22 -26
- package/es/catalog/factories/area-factory.js +13 -15
- package/es/catalog/factories/export.js +6 -10
- package/es/catalog/factories/wall-factory-3d.js +31 -36
- package/es/catalog/factories/wall-factory.js +21 -26
- package/es/catalog/holes/door-closet/planner-element.js +15 -19
- package/es/catalog/holes/door-double/planner-element.js +15 -19
- package/es/catalog/holes/door-exterior/planner-element.js +16 -20
- package/es/catalog/holes/door-interior/planner-element.js +16 -20
- package/es/catalog/holes/door-panic/planner-element.js +7 -11
- package/es/catalog/holes/door-panic-double/planner-element.js +15 -19
- package/es/catalog/holes/door-sliding/planner-element.js +17 -21
- package/es/catalog/holes/doorway-framed/planner-element.js +11 -15
- package/es/catalog/holes/doorway-frameless/planner-element.js +7 -11
- package/es/catalog/holes/export.js +13 -29
- package/es/catalog/holes/window-clear/planner-element.js +10 -14
- package/es/catalog/holes/window-cross/planner-element.js +10 -14
- package/es/catalog/holes/window-double-hung/planner-element.js +10 -14
- package/es/catalog/holes/window-vertical/planner-element.js +10 -14
- package/es/catalog/lines/wall/planner-element.js +2 -5
- package/es/catalog/molding/molding-dcm/planner-element.js +5 -9
- package/es/catalog/molding/molding-fbm/planner-element.js +5 -9
- package/es/catalog/molding/molding-lrm/planner-element.js +5 -9
- package/es/catalog/properties/export.js +20 -31
- package/es/catalog/properties/property-checkbox.js +28 -29
- package/es/catalog/properties/property-color.js +16 -19
- package/es/catalog/properties/property-enum.js +24 -27
- package/es/catalog/properties/property-hidden.js +9 -12
- package/es/catalog/properties/property-lenght-measure.js +38 -41
- package/es/catalog/properties/property-length-measure.js +36 -39
- package/es/catalog/properties/property-length-measure_hole.js +38 -41
- package/es/catalog/properties/property-number.js +17 -20
- package/es/catalog/properties/property-read-only.js +16 -19
- package/es/catalog/properties/property-string.js +16 -19
- package/es/catalog/properties/property-toggle.js +16 -19
- package/es/catalog/properties/shared-property-style.js +1 -3
- package/es/catalog/utils/FuseUtils.js +12 -13
- package/es/catalog/utils/exporter.js +10 -11
- package/es/catalog/utils/geom-utils.js +13 -24
- package/es/catalog/utils/item-loader.js +86 -92
- package/es/catalog/utils/load-obj.js +20 -24
- package/es/catalog/utils/mtl-loader.js +3 -4
- package/es/catalog/utils/obj-loader.js +3 -4
- package/es/class/FuseUtils.js +12 -13
- package/es/class/area.js +24 -24
- package/es/class/export.js +23 -36
- package/es/class/group.js +53 -55
- package/es/class/guide.js +15 -17
- package/es/class/hole.js +83 -85
- package/es/class/item.js +155 -155
- package/es/class/layer.js +59 -61
- package/es/class/line.js +135 -138
- package/es/class/project.js +93 -94
- package/es/class/vertex.js +29 -31
- package/es/components/content.js +19 -23
- package/es/components/disclaimer/disclaimer.js +10 -13
- package/es/components/export.js +8 -13
- package/es/components/style/button.js +25 -25
- package/es/components/style/cancel-button.js +7 -10
- package/es/components/style/content-container.js +11 -12
- package/es/components/style/content-title.js +13 -15
- package/es/components/style/delete-button.js +8 -12
- package/es/components/style/export.js +30 -46
- package/es/components/style/form-block.js +10 -11
- package/es/components/style/form-color-input.js +7 -10
- package/es/components/style/form-label.js +10 -11
- package/es/components/style/form-number-input.js +45 -43
- package/es/components/style/form-number-input_2.js +41 -39
- package/es/components/style/form-select.js +19 -20
- package/es/components/style/form-slider.js +10 -13
- package/es/components/style/form-submit-button.js +8 -12
- package/es/components/style/form-text-input.js +30 -28
- package/es/components/viewer2d/area.js +17 -20
- package/es/components/viewer2d/export.js +30 -46
- package/es/components/viewer2d/grids/grid-horizontal-streak.js +10 -13
- package/es/components/viewer2d/grids/grid-streak.js +10 -13
- package/es/components/viewer2d/grids/grid-vertical-streak.js +10 -13
- package/es/components/viewer2d/grids/grids.js +10 -14
- package/es/components/viewer2d/group.js +15 -19
- package/es/components/viewer2d/item.js +61 -65
- package/es/components/viewer2d/layer.js +23 -26
- package/es/components/viewer2d/line.js +101 -106
- package/es/components/viewer2d/ruler.js +22 -25
- package/es/components/viewer2d/rulerDist.js +21 -24
- package/es/components/viewer2d/rulerX.js +46 -44
- package/es/components/viewer2d/rulerY.js +44 -42
- package/es/components/viewer2d/scene.js +34 -34
- package/es/components/viewer2d/snap.js +13 -17
- package/es/components/viewer2d/state.js +18 -22
- package/es/components/viewer2d/utils.js +24 -33
- package/es/components/viewer2d/vertex.js +8 -12
- package/es/components/viewer2d/viewer2d.js +156 -159
- package/es/components/viewer3d/camera-controls-module/camera-controls.module.js +21 -19
- package/es/components/viewer3d/dcm.js +1 -3
- package/es/components/viewer3d/fbm.js +1 -3
- package/es/components/viewer3d/front3D.js +12 -16
- package/es/components/viewer3d/grid-creator.js +8 -12
- package/es/components/viewer3d/grids/grid-horizontal-streak.js +6 -9
- package/es/components/viewer3d/grids/grid-streak.js +5 -8
- package/es/components/viewer3d/grids/grid-vertical-streak.js +6 -9
- package/es/components/viewer3d/libs/first-person-controls.js +2 -5
- package/es/components/viewer3d/libs/helvetiker_regular.typeface.js +1 -3
- package/es/components/viewer3d/libs/mtl-loader.js +1 -3
- package/es/components/viewer3d/libs/obj-loader.js +1 -3
- package/es/components/viewer3d/libs/orbit-controls.js +2 -4
- package/es/components/viewer3d/libs/pointer-lock-controls.js +2 -4
- package/es/components/viewer3d/lrm.js +1 -3
- package/es/components/viewer3d/model.js +1 -3
- package/es/components/viewer3d/pointer-lock-navigation.js +3 -6
- package/es/components/viewer3d/ruler-utils/itemRect.js +18 -21
- package/es/components/viewer3d/ruler-utils/layer3D.js +59 -62
- package/es/components/viewer3d/ruler-utils/ruler3D.js +42 -43
- package/es/components/viewer3d/ruler-utils/scene3D.js +9 -13
- package/es/components/viewer3d/ruler-utils/state3D.js +4 -7
- package/es/components/viewer3d/scene-creator.js +197 -223
- package/es/components/viewer3d/three-memory-cleaner.js +3 -7
- package/es/components/viewer3d/viewer3d-first-person.js +42 -42
- package/es/components/viewer3d/viewer3d.js +200 -198
- package/es/constants.js +349 -354
- package/es/index.js +7 -11
- package/es/models.js +193 -191
- package/es/plugins/SVGLoader.js +48 -49
- package/es/plugins/autosave.js +3 -5
- package/es/plugins/console-debugger.js +6 -7
- package/es/plugins/export.js +8 -13
- package/es/plugins/keyboard.js +29 -31
- package/es/reducers/areas-reducer.js +7 -9
- package/es/reducers/export.js +24 -37
- package/es/reducers/groups-reducer.js +31 -33
- package/es/reducers/holes-reducer.js +43 -45
- package/es/reducers/items-reducer.js +106 -108
- package/es/reducers/lines-reducer.js +28 -30
- package/es/reducers/project-reducer.js +105 -107
- package/es/reducers/reducer.js +16 -19
- package/es/reducers/scene-reducer.js +15 -17
- package/es/reducers/user-reducer.js +5 -7
- package/es/reducers/vertices-reducer.js +11 -13
- package/es/reducers/viewer2d-reducer.js +18 -20
- package/es/reducers/viewer3d-reducer.js +16 -18
- package/es/shared-style.js +10 -12
- package/es/styles/export.js +3 -6
- package/es/translator/en.js +1 -3
- package/es/translator/it.js +1 -3
- package/es/translator/ru.js +1 -3
- package/es/translator/translator.js +13 -15
- package/es/utils/browser.js +2 -5
- package/es/utils/convert-units-lite.js +1 -3
- package/es/utils/email-validator.js +1 -3
- package/es/utils/export.js +15 -29
- package/es/utils/geometry.js +190 -280
- package/es/utils/get-edges-of-subgraphs.js +2 -5
- package/es/utils/graph-cycles.js +8 -7
- package/es/utils/graph-inner-cycles.js +10 -14
- package/es/utils/graph.js +9 -13
- package/es/utils/helper.js +41 -58
- package/es/utils/history.js +8 -11
- package/es/utils/id-broker.js +8 -11
- package/es/utils/logger.js +1 -3
- package/es/utils/math.js +5 -8
- package/es/utils/molding.js +130 -146
- package/es/utils/name-generator.js +7 -9
- package/es/utils/objects-utils.js +7 -14
- package/es/utils/phone-validator.js +1 -3
- package/es/utils/process-black-list.js +5 -6
- package/es/utils/react-if.js +7 -9
- package/es/utils/snap-scene.js +27 -30
- package/es/utils/snap.js +53 -57
- package/es/utils/summarizeCart.js +1 -3
- package/es/utils/threeCSG.es6.js +13 -17
- package/es/version.js +1 -3
- package/package.json +1 -1
package/es/utils/molding.js
CHANGED
|
@@ -1,43 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
exports.isLinesOverlapped = isLinesOverlapped;
|
|
17
|
-
exports.isSameMoldingLayoutpos = isSameMoldingLayoutpos;
|
|
18
|
-
exports.mergeOverlappedLines = mergeOverlappedLines;
|
|
19
|
-
exports.sortItemsByDistance = sortItemsByDistance;
|
|
20
|
-
exports.tryMergeMDItem = tryMergeMDItem;
|
|
21
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
|
|
22
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
|
|
23
|
-
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/createForOfIteratorHelper"));
|
|
24
|
-
var _constants = require("../constants");
|
|
25
|
-
var Three = _interopRequireWildcard(require("three"));
|
|
26
|
-
var _convertUnitsLite = require("./convert-units-lite");
|
|
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 getItemRect(item) {
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
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; } } }; }
|
|
6
|
+
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; } }
|
|
7
|
+
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; }
|
|
8
|
+
import { BASE_CABINET_LAYOUTPOS, BOTTOM_MOLDING_LOCATION, EPSILON, MIDDLE_MOLDING_LOCATION, MOLDING_LOCATIONS, OVERLAP_INCLUDED, OVERLAP_LINK, OVERLAP_SAME, OVERLAP_SOME, TALL_CABINET_LAYOUTPOS, TOP_MOLDING_LOCATION, WALL_CABINET_LAYOUTPOS } from "../constants";
|
|
9
|
+
import * as Three from 'three';
|
|
10
|
+
import { convert } from "./convert-units-lite";
|
|
11
|
+
import IDBroker from "./id-broker";
|
|
12
|
+
import { returnReplaceableDeepSearchType } from "../components/viewer2d/utils";
|
|
13
|
+
import { GeometryUtils } from "./export";
|
|
14
|
+
import { isEmpty } from "./helper";
|
|
15
|
+
export function getItemRect(item) {
|
|
32
16
|
var x = item.x;
|
|
33
17
|
var y = item.y;
|
|
34
18
|
var rotRad = item.rotation / 180 * Math.PI;
|
|
35
19
|
var itemWidth = item.properties.get('width').get('_length');
|
|
36
20
|
var itemWidthUnit = item.properties.get('width').get('_unit') || 'cm';
|
|
37
|
-
itemWidth =
|
|
21
|
+
itemWidth = convert(itemWidth / 2).from(itemWidthUnit).to('cm');
|
|
38
22
|
var itemDepth = item.properties.get('depth').get('_length');
|
|
39
23
|
var itemDepthUnit = item.properties.get('depth').get('_unit') || 'cm';
|
|
40
|
-
itemDepth =
|
|
24
|
+
itemDepth = convert(itemDepth / 2).from(itemDepthUnit).to('cm');
|
|
41
25
|
var mx = x - itemWidth * Math.cos(rotRad);
|
|
42
26
|
var my = y - itemWidth * Math.sin(rotRad);
|
|
43
27
|
var x0 = mx + itemDepth * Math.sin(rotRad);
|
|
@@ -64,17 +48,17 @@ function getItemRect(item) {
|
|
|
64
48
|
}]
|
|
65
49
|
};
|
|
66
50
|
}
|
|
67
|
-
function hasMoldingLayout(molding, layoutpos) {
|
|
51
|
+
export function hasMoldingLayout(molding, layoutpos) {
|
|
68
52
|
var types = molding === null || molding === void 0 ? void 0 : molding.molding_type;
|
|
69
53
|
return (Array.isArray(types) || typeof types === 'string') && types.includes(layoutpos);
|
|
70
54
|
}
|
|
71
|
-
function isEnableItemForMolding(layer, selItem) {
|
|
55
|
+
export function isEnableItemForMolding(layer, selItem) {
|
|
72
56
|
var molding = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
73
|
-
var allLineRects =
|
|
74
|
-
var result = !
|
|
57
|
+
var allLineRects = GeometryUtils.buildRectFromLines(layer, GeometryUtils.getAllLines(layer));
|
|
58
|
+
var result = !isEmpty(selItem) && selItem.category === 'cabinet' && (selItem.layoutpos === BASE_CABINET_LAYOUTPOS && !GeometryUtils.isSnappedLine(getItemRect(selItem), allLineRects) || (selItem.layoutpos === WALL_CABINET_LAYOUTPOS || selItem.layoutpos === TALL_CABINET_LAYOUTPOS) && GeometryUtils.isSnappedLine(getItemRect(selItem), allLineRects));
|
|
75
59
|
|
|
76
60
|
// check this item is enable for any molding
|
|
77
|
-
if (
|
|
61
|
+
if (isEmpty(molding)) return result;
|
|
78
62
|
// check this item is enable for specified molding
|
|
79
63
|
else return result && hasMoldingLayout(molding, selItem.layoutpos);
|
|
80
64
|
}
|
|
@@ -98,66 +82,66 @@ function getDelta(selRectPos1, selRectPos2, curRectPos1, curRectPos2) {
|
|
|
98
82
|
// GeometryUtils.verticesDistance(curRectPos2, curRectPos1) -
|
|
99
83
|
// GeometryUtils.verticesDistance(selRectPos1, selRectPos2)
|
|
100
84
|
// )
|
|
101
|
-
Math.abs(
|
|
85
|
+
Math.abs(GeometryUtils.verticesDistance(curRectPos1, selRectPos1) + GeometryUtils.verticesDistance(selRectPos2, curRectPos2) - GeometryUtils.verticesDistance(curRectPos2, curRectPos1) - GeometryUtils.verticesDistance(selRectPos1, selRectPos2))
|
|
102
86
|
);
|
|
103
87
|
}
|
|
104
|
-
function isItemSnappedItem(selItem, curItem) {
|
|
88
|
+
export function isItemSnappedItem(selItem, curItem) {
|
|
105
89
|
var selRect = getItemRect(selItem).rect;
|
|
106
90
|
var curRect = getItemRect(curItem).rect;
|
|
107
|
-
var flag30 = getDelta(selRect[3], selRect[0], curRect[1], curRect[2]) <
|
|
108
|
-
var flag21 = getDelta(selRect[2], selRect[1], curRect[0], curRect[3]) <
|
|
109
|
-
var flag23 = getDelta(selRect[2], selRect[3], curRect[2], curRect[3]) <
|
|
110
|
-
var flag01 = getDelta(selRect[1], selRect[0], curRect[0], curRect[3]) <
|
|
111
|
-
var flag03 = getDelta(selRect[0], selRect[3], curRect[1], curRect[0]) <
|
|
91
|
+
var flag30 = getDelta(selRect[3], selRect[0], curRect[1], curRect[2]) < EPSILON;
|
|
92
|
+
var flag21 = getDelta(selRect[2], selRect[1], curRect[0], curRect[3]) < EPSILON;
|
|
93
|
+
var flag23 = getDelta(selRect[2], selRect[3], curRect[2], curRect[3]) < EPSILON;
|
|
94
|
+
var flag01 = getDelta(selRect[1], selRect[0], curRect[0], curRect[3]) < EPSILON;
|
|
95
|
+
var flag03 = getDelta(selRect[0], selRect[3], curRect[1], curRect[0]) < EPSILON;
|
|
112
96
|
return flag30 || flag21 || flag23 || flag01 || flag03;
|
|
113
97
|
}
|
|
114
|
-
function isItemSnappedGroup(selItem, itemGroup) {
|
|
98
|
+
export function isItemSnappedGroup(selItem, itemGroup) {
|
|
115
99
|
return itemGroup.some(function (curItem) {
|
|
116
100
|
return isItemSnappedItem(selItem, curItem);
|
|
117
101
|
});
|
|
118
102
|
}
|
|
119
|
-
function sortItemsByDistance(items, selItem) {
|
|
103
|
+
export function sortItemsByDistance(items, selItem) {
|
|
120
104
|
items.sort(function (a, b) {
|
|
121
|
-
return
|
|
105
|
+
return GeometryUtils.pointsDistance(a.x, a.y, selItem.x, selItem.y) - GeometryUtils.pointsDistance(b.x, b.y, selItem.x, selItem.y);
|
|
122
106
|
});
|
|
123
107
|
return items;
|
|
124
108
|
}
|
|
125
|
-
function isSameMoldingLayoutpos(curItem, item) {
|
|
126
|
-
return curItem.layoutpos ===
|
|
109
|
+
export function isSameMoldingLayoutpos(curItem, item) {
|
|
110
|
+
return curItem.layoutpos === BASE_CABINET_LAYOUTPOS && curItem.layoutpos === item.layoutpos || [WALL_CABINET_LAYOUTPOS, TALL_CABINET_LAYOUTPOS].includes(curItem.layoutpos) && [WALL_CABINET_LAYOUTPOS, TALL_CABINET_LAYOUTPOS].includes(item.layoutpos);
|
|
127
111
|
}
|
|
128
|
-
function isItemSameItemByLocation(item1, item2, location) {
|
|
112
|
+
export function isItemSameItemByLocation(item1, item2, location) {
|
|
129
113
|
var item1Altitude = item1.properties.get('altitude').get('_length');
|
|
130
114
|
var item1AltitudeUnit = item1.properties.get('altitude').get('_unit');
|
|
131
|
-
item1Altitude =
|
|
115
|
+
item1Altitude = convert(item1Altitude).from(item1AltitudeUnit).to('cm');
|
|
132
116
|
var item1Height = item1.properties.get('height').get('_length');
|
|
133
117
|
var item1HeightUnit = item1.properties.get('height').get('_unit');
|
|
134
|
-
item1Height =
|
|
118
|
+
item1Height = convert(item1Height).from(item1HeightUnit).to('cm');
|
|
135
119
|
var item2Altitude = item2.properties.get('altitude').get('_length');
|
|
136
120
|
var item2AltitudeUnit = item2.properties.get('altitude').get('_unit');
|
|
137
|
-
item2Altitude =
|
|
121
|
+
item2Altitude = convert(item2Altitude).from(item2AltitudeUnit).to('cm');
|
|
138
122
|
var item2Height = item2.properties.get('height').get('_length');
|
|
139
123
|
var item2HeightUnit = item2.properties.get('height').get('_unit');
|
|
140
|
-
item2Height =
|
|
124
|
+
item2Height = convert(item2Height).from(item2HeightUnit).to('cm');
|
|
141
125
|
var flag = false;
|
|
142
126
|
switch (location) {
|
|
143
|
-
case
|
|
144
|
-
if (
|
|
127
|
+
case TOP_MOLDING_LOCATION:
|
|
128
|
+
if (GeometryUtils.sameDistances(item1Altitude + item1Height, item2Altitude + item2Height)) flag = true;
|
|
145
129
|
break;
|
|
146
|
-
case
|
|
147
|
-
if (
|
|
130
|
+
case MIDDLE_MOLDING_LOCATION:
|
|
131
|
+
if (GeometryUtils.sameDistances(item1Altitude + item1Height / 2, item2Altitude + item2Height / 2)) flag = true;
|
|
148
132
|
break;
|
|
149
|
-
case
|
|
150
|
-
if (
|
|
133
|
+
case BOTTOM_MOLDING_LOCATION:
|
|
134
|
+
if (GeometryUtils.sameDistances(item1Altitude, item2Altitude)) flag = true;
|
|
151
135
|
break;
|
|
152
136
|
}
|
|
153
137
|
return flag;
|
|
154
138
|
}
|
|
155
|
-
function tryMergeMDItem(layer, selItem, curItem, itemGroup, molding) {
|
|
139
|
+
export function tryMergeMDItem(layer, selItem, curItem, itemGroup, molding) {
|
|
156
140
|
return isSameMoldingLayoutpos(selItem, curItem) && isEnableItemForMolding(layer, curItem, molding) && isItemSnappedGroup(curItem, itemGroup) && !itemGroup.some(function (item) {
|
|
157
141
|
return item.id === curItem.id;
|
|
158
142
|
}) && isItemSameItemByLocation(selItem, curItem, molding.location_type);
|
|
159
143
|
}
|
|
160
|
-
function getItemGroupFromMolding(layer, curItem, molding) {
|
|
144
|
+
export function getItemGroupFromMolding(layer, curItem, molding) {
|
|
161
145
|
var selectedItem = layer.getIn(['items', layer.selected.toJS().items[0]]);
|
|
162
146
|
var itemGroup = [curItem];
|
|
163
147
|
var temp_layer_items = layer.items.toArray().filter(function (item) {
|
|
@@ -184,7 +168,7 @@ function tryMergeItemWithLocation(curItem, itemGroup, location) {
|
|
|
184
168
|
* @param {*} items - Mergable snapped item group, if [items] is null then get all MG array of layer
|
|
185
169
|
* @returns MG array
|
|
186
170
|
*/
|
|
187
|
-
function getAllMoldingGroups(layer) {
|
|
171
|
+
export function getAllMoldingGroups(layer) {
|
|
188
172
|
var items = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
189
173
|
if (items === null) items = layer.items.toArray();
|
|
190
174
|
var MGArray = [];
|
|
@@ -206,7 +190,7 @@ function getAllMoldingGroups(layer) {
|
|
|
206
190
|
return it.category === 'cabinet' && isSameMoldingLayoutpos(curItem, it) && it.id !== curItem.id;
|
|
207
191
|
});
|
|
208
192
|
temp_items = sortItemsByDistance(temp_items, curItem);
|
|
209
|
-
|
|
193
|
+
MOLDING_LOCATIONS.forEach(function (location) {
|
|
210
194
|
if (!MGArray.some(function (mg) {
|
|
211
195
|
return mg.items.some(function (it) {
|
|
212
196
|
return it.id === curItem.id;
|
|
@@ -229,7 +213,7 @@ function getAllMoldingGroups(layer) {
|
|
|
229
213
|
}
|
|
230
214
|
} while (isChangedItemGroup);
|
|
231
215
|
MGArray.push({
|
|
232
|
-
id:
|
|
216
|
+
id: IDBroker.acquireID(),
|
|
233
217
|
items: itemGroup,
|
|
234
218
|
location_type: location,
|
|
235
219
|
molding: null,
|
|
@@ -246,18 +230,18 @@ function getAllMoldingGroups(layer) {
|
|
|
246
230
|
});
|
|
247
231
|
return MGArray;
|
|
248
232
|
}
|
|
249
|
-
function getLinesOfItem(item, allLineRects, catalog) {
|
|
233
|
+
export function getLinesOfItem(item, allLineRects, catalog) {
|
|
250
234
|
var lines = [];
|
|
251
235
|
var outline = null;
|
|
252
236
|
var element = catalog.elements[item.get('type')];
|
|
253
|
-
if (!element) element = catalog.elements[
|
|
237
|
+
if (!element) element = catalog.elements[returnReplaceableDeepSearchType(item.get('type'))];
|
|
254
238
|
// get edge lines
|
|
255
239
|
var newWidth = item.properties.get('width').get('_length');
|
|
256
240
|
var wUnit = item.properties.get('width').get('_unit') || 'cm';
|
|
257
|
-
newWidth =
|
|
241
|
+
newWidth = convert(newWidth).from(wUnit).to('cm');
|
|
258
242
|
var newDepth = item.properties.get('depth').get('_length');
|
|
259
243
|
var hUnit = item.properties.get('depth').get('_unit') || 'cm';
|
|
260
|
-
newDepth =
|
|
244
|
+
newDepth = convert(newDepth).from(hUnit).to('cm');
|
|
261
245
|
if (item) {
|
|
262
246
|
// Get Outline Data of Selected Item
|
|
263
247
|
outline = element.info.outline;
|
|
@@ -267,12 +251,12 @@ function getLinesOfItem(item, allLineRects, catalog) {
|
|
|
267
251
|
var outlineWidth = outline.svgWidth;
|
|
268
252
|
var outlineHeight = outline.svgHeight;
|
|
269
253
|
var outlinePoints = []; // Hold Points Of SVG
|
|
270
|
-
var _iterator = (
|
|
254
|
+
var _iterator = _createForOfIteratorHelper(outlinePaths),
|
|
271
255
|
_step;
|
|
272
256
|
try {
|
|
273
257
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
274
258
|
var path = _step.value;
|
|
275
|
-
var _iterator2 = (
|
|
259
|
+
var _iterator2 = _createForOfIteratorHelper(path.subPaths),
|
|
276
260
|
_step2;
|
|
277
261
|
try {
|
|
278
262
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
@@ -292,18 +276,18 @@ function getLinesOfItem(item, allLineRects, catalog) {
|
|
|
292
276
|
}
|
|
293
277
|
outline.reverse && outlinePoints.reverse();
|
|
294
278
|
for (var i = 0; i < outlinePoints.length - 1; i++) {
|
|
295
|
-
lines.push([
|
|
279
|
+
lines.push([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), 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.acquireID()]);
|
|
296
280
|
}
|
|
297
281
|
} else {
|
|
298
282
|
var pos = [[-1, -1], [1, -1], [1, 1], [-1, 1]];
|
|
299
283
|
for (var _i = 0; _i < 4; _i++) {
|
|
300
|
-
lines.push([
|
|
284
|
+
lines.push([GeometryUtils.rotatePointAroundPoint(pos[_i][0] * newWidth / 2 + item.x, pos[_i][1] * newDepth / 2 + item.y, item.x, item.y, item.rotation), 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.acquireID()]);
|
|
301
285
|
}
|
|
302
286
|
}
|
|
303
287
|
}
|
|
304
|
-
if (item.layoutpos !==
|
|
288
|
+
if (item.layoutpos !== BASE_CABINET_LAYOUTPOS) {
|
|
305
289
|
lines = lines.filter(function (line) {
|
|
306
|
-
return !
|
|
290
|
+
return !GeometryUtils.isSnappedLine({
|
|
307
291
|
rect: [{
|
|
308
292
|
x: 0,
|
|
309
293
|
y: 0
|
|
@@ -318,29 +302,29 @@ function getLinesOfItem(item, allLineRects, catalog) {
|
|
|
318
302
|
}
|
|
319
303
|
function isParallelLines(line1, line2) {
|
|
320
304
|
var isParallel = false;
|
|
321
|
-
if (Math.abs(line1[0].y - line1[1].y) <=
|
|
322
|
-
if (Math.abs(line1[0].x - line1[1].x) <=
|
|
323
|
-
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)) <=
|
|
305
|
+
if (Math.abs(line1[0].y - line1[1].y) <= EPSILON && Math.abs(line2[0].y - line2[1].y) <= EPSILON) isParallel = true;
|
|
306
|
+
if (Math.abs(line1[0].x - line1[1].x) <= EPSILON && Math.abs(line2[0].x - line2[1].x) <= EPSILON) isParallel = true;
|
|
307
|
+
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)) <= EPSILON) isParallel = true;
|
|
324
308
|
if (isParallel) {
|
|
325
309
|
return true;
|
|
326
310
|
}
|
|
327
311
|
return false;
|
|
328
312
|
}
|
|
329
|
-
function isLinesOverlapped(line1, line2) {
|
|
313
|
+
export function isLinesOverlapped(line1, line2) {
|
|
330
314
|
return isParallelLines(line1, line2) && line1.some(function (l1) {
|
|
331
315
|
return line2.some(function (l2) {
|
|
332
|
-
return
|
|
316
|
+
return GeometryUtils.samePoints(l1, l2);
|
|
333
317
|
});
|
|
334
318
|
});
|
|
335
319
|
}
|
|
336
|
-
function mergeOverlappedLines(line1, line2) {
|
|
320
|
+
export function mergeOverlappedLines(line1, line2) {
|
|
337
321
|
var line1_idx = 0,
|
|
338
322
|
line2_idx = 0;
|
|
339
323
|
line1.forEach(function (l1, idx1) {
|
|
340
324
|
if (idx1 !== line1.length - 1) {
|
|
341
325
|
line2.forEach(function (l2, idx2) {
|
|
342
326
|
if (idx2 !== line2.length - 1) {
|
|
343
|
-
if (
|
|
327
|
+
if (GeometryUtils.samePoints(l1, l2)) {
|
|
344
328
|
line1_idx = idx1;
|
|
345
329
|
line2_idx = idx2;
|
|
346
330
|
}
|
|
@@ -351,9 +335,9 @@ function mergeOverlappedLines(line1, line2) {
|
|
|
351
335
|
//If line1 's end point and line2 's start point is same, two lines merge into a line with
|
|
352
336
|
//the line1's start point as the start point and line2's end point as the end point.
|
|
353
337
|
if (line1_idx === 1) {
|
|
354
|
-
return [line1[1 - line1_idx], line2[1 - line2_idx],
|
|
338
|
+
return [line1[1 - line1_idx], line2[1 - line2_idx], IDBroker.acquireID()];
|
|
355
339
|
} else {
|
|
356
|
-
return [line2[1 - line2_idx], line1[1 - line1_idx],
|
|
340
|
+
return [line2[1 - line2_idx], line1[1 - line1_idx], IDBroker.acquireID()];
|
|
357
341
|
}
|
|
358
342
|
}
|
|
359
343
|
|
|
@@ -364,12 +348,12 @@ function mergeOverlappedLines(line1, line2) {
|
|
|
364
348
|
* @param {*} catalog
|
|
365
349
|
* @returns contour line array of moldingGroup items
|
|
366
350
|
*/
|
|
367
|
-
function getLinesFromItems2(moldingGroup, layer, catalog) {
|
|
351
|
+
export function getLinesFromItems2(moldingGroup, layer, catalog) {
|
|
368
352
|
// wall lines
|
|
369
|
-
var allLineRects =
|
|
353
|
+
var allLineRects = GeometryUtils.buildRectFromLines(layer, GeometryUtils.getAllLines(layer));
|
|
370
354
|
var MGlines = [];
|
|
371
355
|
var MGlinesOtherSnapped = [];
|
|
372
|
-
var items = (
|
|
356
|
+
var items = _toConsumableArray(moldingGroup.items);
|
|
373
357
|
// The other item's lines (these items are snapped to the moldingGroup items)
|
|
374
358
|
var itemsOtherSnapped = layer.items.toArray().filter(function (item) {
|
|
375
359
|
if (items.some(function (it) {
|
|
@@ -379,17 +363,17 @@ function getLinesFromItems2(moldingGroup, layer, catalog) {
|
|
|
379
363
|
var itemLines = getLinesOfItem(item, allLineRects, catalog);
|
|
380
364
|
var itemAltitude = item.properties.get('altitude').get('_length');
|
|
381
365
|
var itemAltitudeUnit = item.properties.get('altitude').get('_unit');
|
|
382
|
-
itemAltitude =
|
|
366
|
+
itemAltitude = convert(itemAltitude).from(itemAltitudeUnit).to('cm');
|
|
383
367
|
var itemHeight = item.properties.get('height').get('_length');
|
|
384
368
|
var itemHeightUnit = item.properties.get('height').get('_unit');
|
|
385
|
-
itemHeight =
|
|
369
|
+
itemHeight = convert(itemHeight).from(itemHeightUnit).to('cm');
|
|
386
370
|
itemLines.forEach(function (line) {
|
|
387
371
|
line.push({
|
|
388
372
|
altitude: itemAltitude,
|
|
389
373
|
height: itemHeight
|
|
390
374
|
});
|
|
391
375
|
});
|
|
392
|
-
MGlinesOtherSnapped = [].concat((
|
|
376
|
+
MGlinesOtherSnapped = [].concat(_toConsumableArray(MGlinesOtherSnapped), _toConsumableArray(itemLines));
|
|
393
377
|
return true;
|
|
394
378
|
} else return false;
|
|
395
379
|
});
|
|
@@ -398,10 +382,10 @@ function getLinesFromItems2(moldingGroup, layer, catalog) {
|
|
|
398
382
|
items.forEach(function (item) {
|
|
399
383
|
var itemAltitude = item.properties.get('altitude').get('_length');
|
|
400
384
|
var itemAltitudeUnit = item.properties.get('altitude').get('_unit');
|
|
401
|
-
itemAltitude =
|
|
385
|
+
itemAltitude = convert(itemAltitude).from(itemAltitudeUnit).to('cm');
|
|
402
386
|
var itemHeight = item.properties.get('height').get('_length');
|
|
403
387
|
var itemHeightUnit = item.properties.get('height').get('_unit');
|
|
404
|
-
itemHeight =
|
|
388
|
+
itemHeight = convert(itemHeight).from(itemHeightUnit).to('cm');
|
|
405
389
|
var itemLines = getLinesOfItem(item, allLineRects, catalog);
|
|
406
390
|
|
|
407
391
|
// remove the edge that overlapped with other snapped items
|
|
@@ -416,17 +400,17 @@ function getLinesFromItems2(moldingGroup, layer, catalog) {
|
|
|
416
400
|
for (var j = 0; j < MGlinesOtherSnapped.length; j++) {
|
|
417
401
|
var bCheck = false;
|
|
418
402
|
switch (moldingGroup.location_type) {
|
|
419
|
-
case
|
|
403
|
+
case TOP_MOLDING_LOCATION:
|
|
420
404
|
bCheck = MGlinesOtherSnapped[j][3].altitude + MGlinesOtherSnapped[j][3].height > itemAltitude + itemHeight;
|
|
421
405
|
break;
|
|
422
|
-
case
|
|
406
|
+
case MIDDLE_MOLDING_LOCATION:
|
|
423
407
|
bCheck = true;
|
|
424
408
|
break;
|
|
425
|
-
case
|
|
409
|
+
case BOTTOM_MOLDING_LOCATION:
|
|
426
410
|
bCheck = MGlinesOtherSnapped[j][3].altitude < itemAltitude;
|
|
427
411
|
break;
|
|
428
412
|
}
|
|
429
|
-
if (item.category !== 'cabinet' || ![
|
|
413
|
+
if (item.category !== 'cabinet' || ![BASE_CABINET_LAYOUTPOS, WALL_CABINET_LAYOUTPOS, TALL_CABINET_LAYOUTPOS].includes(item.layoutpos)) bCheck = true;
|
|
430
414
|
if (bCheck) {
|
|
431
415
|
var destLine = {
|
|
432
416
|
x1: MGlinesOtherSnapped[j][0].x,
|
|
@@ -434,8 +418,8 @@ function getLinesFromItems2(moldingGroup, layer, catalog) {
|
|
|
434
418
|
x2: MGlinesOtherSnapped[j][1].x,
|
|
435
419
|
y2: MGlinesOtherSnapped[j][1].y
|
|
436
420
|
};
|
|
437
|
-
var rst =
|
|
438
|
-
if (rst.result ===
|
|
421
|
+
var rst = GeometryUtils.relationshipOfTwoOverlappedLines(srcLine, destLine);
|
|
422
|
+
if (rst.result === OVERLAP_SAME || rst.result === OVERLAP_INCLUDED) {
|
|
439
423
|
ret = false;
|
|
440
424
|
break;
|
|
441
425
|
}
|
|
@@ -443,7 +427,7 @@ function getLinesFromItems2(moldingGroup, layer, catalog) {
|
|
|
443
427
|
}
|
|
444
428
|
return ret;
|
|
445
429
|
});
|
|
446
|
-
MGlines = [].concat((
|
|
430
|
+
MGlines = [].concat(_toConsumableArray(MGlines), _toConsumableArray(itemLines));
|
|
447
431
|
});
|
|
448
432
|
|
|
449
433
|
// Filtering overlapped edges and get contour edges
|
|
@@ -464,16 +448,16 @@ function getLinesFromItems2(moldingGroup, layer, catalog) {
|
|
|
464
448
|
x2: MGlines[j][1].x,
|
|
465
449
|
y2: MGlines[j][1].y
|
|
466
450
|
};
|
|
467
|
-
var rst =
|
|
468
|
-
if (rst.result ===
|
|
451
|
+
var rst = GeometryUtils.relationshipOfTwoOverlappedLines(srcLine, destLine);
|
|
452
|
+
if (rst.result === OVERLAP_SAME || rst.result === OVERLAP_INCLUDED) {
|
|
469
453
|
removeLineIds.push(i);
|
|
470
454
|
return 1; // break
|
|
471
|
-
} else if (rst.result ===
|
|
455
|
+
} else if (rst.result === OVERLAP_SOME) {
|
|
472
456
|
removeLineIds.push(i);
|
|
473
457
|
var lineSegs = getTrimmedContourLineSegs(rst.trimmedSegs, MGlines.filter(function (v, idx) {
|
|
474
458
|
return idx !== i && idx !== j;
|
|
475
459
|
}), 0);
|
|
476
|
-
if (lineSegs.length > 0) newLines = [].concat((
|
|
460
|
+
if (lineSegs.length > 0) newLines = [].concat(_toConsumableArray(newLines), _toConsumableArray(lineSegs));
|
|
477
461
|
return 1; // break
|
|
478
462
|
}
|
|
479
463
|
},
|
|
@@ -492,7 +476,7 @@ function getLinesFromItems2(moldingGroup, layer, catalog) {
|
|
|
492
476
|
return idx === id;
|
|
493
477
|
});
|
|
494
478
|
});
|
|
495
|
-
if (newLines.length > 0) MGlines = [].concat((
|
|
479
|
+
if (newLines.length > 0) MGlines = [].concat(_toConsumableArray(MGlines), _toConsumableArray(newLines));
|
|
496
480
|
|
|
497
481
|
// merge the collinear linked lines to one line
|
|
498
482
|
var newMGlines = [];
|
|
@@ -552,15 +536,15 @@ function getMergedLine(line, MGlines, cnt) {
|
|
|
552
536
|
x2: newMGlines[i][1].x,
|
|
553
537
|
y2: newMGlines[i][1].y
|
|
554
538
|
};
|
|
555
|
-
var rst =
|
|
556
|
-
if (rst.result ===
|
|
539
|
+
var rst = GeometryUtils.relationshipOfTwoOverlappedLines(srcLine, destLine);
|
|
540
|
+
if (rst.result === OVERLAP_LINK) {
|
|
557
541
|
var mergedLine = [{
|
|
558
542
|
x: rst.linkedLine.x1,
|
|
559
543
|
y: rst.linkedLine.y1
|
|
560
544
|
}, {
|
|
561
545
|
x: rst.linkedLine.x2,
|
|
562
546
|
y: rst.linkedLine.y2
|
|
563
|
-
},
|
|
547
|
+
}, IDBroker.acquireID()];
|
|
564
548
|
mergeResult = getMergedLine(mergedLine, newMGlines.filter(function (v, idx) {
|
|
565
549
|
return idx !== i;
|
|
566
550
|
}), cnt);
|
|
@@ -605,15 +589,15 @@ function getTrimmedContourLineSegs(lineSegs, otherLines, cnt) {
|
|
|
605
589
|
x2: otherLines[j][1].x,
|
|
606
590
|
y2: otherLines[j][1].y
|
|
607
591
|
};
|
|
608
|
-
var rst =
|
|
609
|
-
if (rst.result ==
|
|
592
|
+
var rst = GeometryUtils.relationshipOfTwoOverlappedLines(srcLine, destLine);
|
|
593
|
+
if (rst.result == OVERLAP_SAME || rst.result == OVERLAP_INCLUDED) {
|
|
610
594
|
bContourSeg = false;
|
|
611
595
|
return 0; // break
|
|
612
|
-
} else if (rst.result ==
|
|
596
|
+
} else if (rst.result == OVERLAP_SOME) {
|
|
613
597
|
var tLineSegs = getTrimmedContourLineSegs(rst.trimmedSegs, otherLines.filter(function (v, idx) {
|
|
614
598
|
return idx !== j;
|
|
615
599
|
}), cnt);
|
|
616
|
-
if (tLineSegs.length > 0) returnSegs = [].concat((
|
|
600
|
+
if (tLineSegs.length > 0) returnSegs = [].concat(_toConsumableArray(returnSegs), _toConsumableArray(tLineSegs));
|
|
617
601
|
bContourSeg = false;
|
|
618
602
|
return 0; // break
|
|
619
603
|
}
|
|
@@ -629,7 +613,7 @@ function getTrimmedContourLineSegs(lineSegs, otherLines, cnt) {
|
|
|
629
613
|
}, {
|
|
630
614
|
x: lineSegs[i].x2,
|
|
631
615
|
y: lineSegs[i].y2
|
|
632
|
-
},
|
|
616
|
+
}, IDBroker.acquireID()]);
|
|
633
617
|
}
|
|
634
618
|
return returnSegs;
|
|
635
619
|
} catch (e) {
|
|
@@ -637,9 +621,9 @@ function getTrimmedContourLineSegs(lineSegs, otherLines, cnt) {
|
|
|
637
621
|
return [];
|
|
638
622
|
}
|
|
639
623
|
}
|
|
640
|
-
function getLinesFromItems(moldingGroup, layer, catalog) {
|
|
641
|
-
var allLineRects =
|
|
642
|
-
var items = (
|
|
624
|
+
export function getLinesFromItems(moldingGroup, layer, catalog) {
|
|
625
|
+
var allLineRects = GeometryUtils.buildRectFromLines(layer, GeometryUtils.getAllLines(layer));
|
|
626
|
+
var items = _toConsumableArray(moldingGroup.items);
|
|
643
627
|
var MGlines = getLinesOfItem(items[0], allLineRects, catalog);
|
|
644
628
|
items = sortItemsByDistance(items, items[0]);
|
|
645
629
|
var _loop7 = function _loop7() {
|
|
@@ -651,7 +635,7 @@ function getLinesFromItems(moldingGroup, layer, catalog) {
|
|
|
651
635
|
});
|
|
652
636
|
var curItemLine = itemLines[idx];
|
|
653
637
|
if (idx > -1) {
|
|
654
|
-
if (!(
|
|
638
|
+
if (!(GeometryUtils.samePoints(line[0], curItemLine[0]) && GeometryUtils.samePoints(line[1], curItemLine[1]) || GeometryUtils.samePoints(line[0], curItemLine[1]) && GeometryUtils.samePoints(line[1], curItemLine[0]))) {
|
|
655
639
|
var MGLine = mergeOverlappedLines(line, curItemLine);
|
|
656
640
|
temp_MGLines.push(MGLine);
|
|
657
641
|
}
|
|
@@ -678,29 +662,29 @@ function getLinesFromItems(moldingGroup, layer, catalog) {
|
|
|
678
662
|
snapped_other_items.forEach(function (item) {
|
|
679
663
|
var itemAltitude = item.properties.get('altitude').get('_length');
|
|
680
664
|
var itemAltitudeUnit = item.properties.get('altitude').get('_unit');
|
|
681
|
-
itemAltitude =
|
|
665
|
+
itemAltitude = convert(itemAltitude).from(itemAltitudeUnit).to('cm');
|
|
682
666
|
var itemHeight = item.properties.get('height').get('_length');
|
|
683
667
|
var itemHeightUnit = item.properties.get('height').get('_unit');
|
|
684
|
-
itemHeight =
|
|
668
|
+
itemHeight = convert(itemHeight).from(itemHeightUnit).to('cm');
|
|
685
669
|
var mgroupAltitude = items[0].properties.get('altitude').get('_length');
|
|
686
670
|
var mgroupAltitudeUnit = items[0].properties.get('altitude').get('_unit');
|
|
687
|
-
mgroupAltitude =
|
|
671
|
+
mgroupAltitude = convert(mgroupAltitude).from(mgroupAltitudeUnit).to('cm');
|
|
688
672
|
var mgroupHeight = items[0].properties.get('height').get('_length');
|
|
689
673
|
var mgroupHeightUnit = items[0].properties.get('height').get('_unit');
|
|
690
|
-
mgroupHeight =
|
|
674
|
+
mgroupHeight = convert(mgroupHeight).from(mgroupHeightUnit).to('cm');
|
|
691
675
|
var flag = false;
|
|
692
676
|
switch (moldingGroup.location_type) {
|
|
693
|
-
case
|
|
677
|
+
case TOP_MOLDING_LOCATION:
|
|
694
678
|
flag = itemAltitude + itemHeight > mgroupAltitude + mgroupHeight;
|
|
695
679
|
break;
|
|
696
|
-
case
|
|
680
|
+
case MIDDLE_MOLDING_LOCATION:
|
|
697
681
|
flag = true;
|
|
698
682
|
break;
|
|
699
|
-
case
|
|
683
|
+
case BOTTOM_MOLDING_LOCATION:
|
|
700
684
|
flag = itemAltitude < mgroupAltitude;
|
|
701
685
|
break;
|
|
702
686
|
}
|
|
703
|
-
if (item.category !== 'cabinet' || ![
|
|
687
|
+
if (item.category !== 'cabinet' || ![BASE_CABINET_LAYOUTPOS, WALL_CABINET_LAYOUTPOS, TALL_CABINET_LAYOUTPOS].includes(item.layoutpos)) flag = true;
|
|
704
688
|
if (flag) {
|
|
705
689
|
var itemLines = getLinesOfItem(item, allLineRects, catalog);
|
|
706
690
|
var temp_MGLines = [];
|
|
@@ -710,8 +694,8 @@ function getLinesFromItems(moldingGroup, layer, catalog) {
|
|
|
710
694
|
});
|
|
711
695
|
var curITL = itemLines[idx];
|
|
712
696
|
if (idx > -1) {
|
|
713
|
-
if (getDelta(mgl[0], mgl[1], curITL[1], curITL[0]) <
|
|
714
|
-
if (
|
|
697
|
+
if (getDelta(mgl[0], mgl[1], curITL[1], curITL[0]) < EPSILON || getDelta(mgl[0], mgl[1], curITL[0], curITL[1]) < EPSILON) {
|
|
698
|
+
if (GeometryUtils.verticesDistance(mgl[0], mgl[1]) > GeometryUtils.verticesDistance(curITL[0], curITL[1])) {
|
|
715
699
|
var MGLine = mergeOverlappedLines(mgl, curITL);
|
|
716
700
|
temp_MGLines.push(MGLine);
|
|
717
701
|
}
|
|
@@ -729,7 +713,7 @@ function getLinesFromItems(moldingGroup, layer, catalog) {
|
|
|
729
713
|
return MGlines;
|
|
730
714
|
}
|
|
731
715
|
function getMDPoints(newMD) {
|
|
732
|
-
if (newMD.lines.length < 1) return (
|
|
716
|
+
if (newMD.lines.length < 1) return _objectSpread(_objectSpread({}, newMD), {}, {
|
|
733
717
|
pointGroups: []
|
|
734
718
|
});
|
|
735
719
|
// let maxX = newMD.lines[0][0].x,
|
|
@@ -767,13 +751,13 @@ function getMDPoints(newMD) {
|
|
|
767
751
|
x: (maxX + minX) / 2,
|
|
768
752
|
y: (maxY + minY) / 2
|
|
769
753
|
};
|
|
770
|
-
var newSize = (
|
|
754
|
+
var newSize = _objectSpread(_objectSpread({}, newMD.size), {}, {
|
|
771
755
|
width: maxX - minX,
|
|
772
756
|
depth: maxY - minY
|
|
773
757
|
});
|
|
774
758
|
|
|
775
759
|
// get vertex points
|
|
776
|
-
var MDlines = (
|
|
760
|
+
var MDlines = _toConsumableArray(newMD.lines);
|
|
777
761
|
var pointGroups = [[]];
|
|
778
762
|
var flag = 1;
|
|
779
763
|
var i = 0;
|
|
@@ -785,10 +769,10 @@ function getMDPoints(newMD) {
|
|
|
785
769
|
if (flag) {
|
|
786
770
|
var lastPoint = pointGroups[i][pointGroups[i].length - 1];
|
|
787
771
|
var res = MDlines.findIndex(function (a) {
|
|
788
|
-
return
|
|
772
|
+
return GeometryUtils.samePoints({
|
|
789
773
|
x: a[0].x - cPos.x,
|
|
790
774
|
y: a[0].y - cPos.y
|
|
791
|
-
}, lastPoint) ||
|
|
775
|
+
}, lastPoint) || GeometryUtils.samePoints({
|
|
792
776
|
x: a[1].x - cPos.x,
|
|
793
777
|
y: a[1].y - cPos.y
|
|
794
778
|
}, lastPoint);
|
|
@@ -798,7 +782,7 @@ function getMDPoints(newMD) {
|
|
|
798
782
|
x: MDlines[res][0].x - cPos.x,
|
|
799
783
|
y: MDlines[res][0].y - cPos.y
|
|
800
784
|
};
|
|
801
|
-
if (
|
|
785
|
+
if (GeometryUtils.samePoints(newPos, lastPoint)) {
|
|
802
786
|
newPos = {
|
|
803
787
|
x: MDlines[res][1].x - cPos.x,
|
|
804
788
|
y: MDlines[res][1].y - cPos.y
|
|
@@ -812,10 +796,10 @@ function getMDPoints(newMD) {
|
|
|
812
796
|
} else {
|
|
813
797
|
var firstPoint = pointGroups[i][0];
|
|
814
798
|
var _res = MDlines.findIndex(function (a) {
|
|
815
|
-
return
|
|
799
|
+
return GeometryUtils.samePoints({
|
|
816
800
|
x: a[0].x - cPos.x,
|
|
817
801
|
y: a[0].y - cPos.y
|
|
818
|
-
}, firstPoint) ||
|
|
802
|
+
}, firstPoint) || GeometryUtils.samePoints({
|
|
819
803
|
x: a[1].x - cPos.x,
|
|
820
804
|
y: a[1].y - cPos.y
|
|
821
805
|
}, firstPoint);
|
|
@@ -825,13 +809,13 @@ function getMDPoints(newMD) {
|
|
|
825
809
|
x: MDlines[_res][0].x - cPos.x,
|
|
826
810
|
y: MDlines[_res][0].y - cPos.y
|
|
827
811
|
};
|
|
828
|
-
if (
|
|
812
|
+
if (GeometryUtils.samePoints(_newPos, firstPoint)) {
|
|
829
813
|
_newPos = {
|
|
830
814
|
x: MDlines[_res][1].x - cPos.x,
|
|
831
815
|
y: MDlines[_res][1].y - cPos.y
|
|
832
816
|
};
|
|
833
817
|
}
|
|
834
|
-
pointGroups[i] = [new Three.Vector2(_newPos.x, _newPos.y)].concat((
|
|
818
|
+
pointGroups[i] = [new Three.Vector2(_newPos.x, _newPos.y)].concat(_toConsumableArray(pointGroups[i]));
|
|
835
819
|
MDlines.splice(_res, 1);
|
|
836
820
|
} else {
|
|
837
821
|
flag = 1;
|
|
@@ -846,33 +830,33 @@ function getMDPoints(newMD) {
|
|
|
846
830
|
}
|
|
847
831
|
var z = newMD.items[0].properties.get('altitude').get('_length');
|
|
848
832
|
var zUnit = newMD.items[0].properties.get('altitude').get('_unit') || 'cm';
|
|
849
|
-
z =
|
|
833
|
+
z = convert(z).from(zUnit).to('cm');
|
|
850
834
|
var height = newMD.items[0].properties.get('height').get('_length');
|
|
851
835
|
var heightUnit = newMD.items[0].properties.get('height').get('_unit') || 'cm';
|
|
852
|
-
height =
|
|
836
|
+
height = convert(height).from(heightUnit).to('cm');
|
|
853
837
|
switch (newMD.location_type) {
|
|
854
|
-
case
|
|
838
|
+
case TOP_MOLDING_LOCATION:
|
|
855
839
|
z += height;
|
|
856
840
|
break;
|
|
857
|
-
case
|
|
841
|
+
case MIDDLE_MOLDING_LOCATION:
|
|
858
842
|
z += height / 2;
|
|
859
843
|
break;
|
|
860
|
-
case
|
|
844
|
+
case BOTTOM_MOLDING_LOCATION:
|
|
861
845
|
z += 0;
|
|
862
846
|
break;
|
|
863
847
|
default:
|
|
864
848
|
break;
|
|
865
849
|
}
|
|
866
|
-
return (
|
|
850
|
+
return _objectSpread(_objectSpread({}, newMD), {}, {
|
|
867
851
|
pointGroups: pointGroups,
|
|
868
|
-
pos: (
|
|
852
|
+
pos: _objectSpread(_objectSpread({}, cPos), {}, {
|
|
869
853
|
z: z
|
|
870
854
|
}),
|
|
871
855
|
size: newSize
|
|
872
856
|
});
|
|
873
857
|
}
|
|
874
|
-
function createMonldingGroup(oldMG, layer, molding, catalog) {
|
|
875
|
-
var newMG = (
|
|
858
|
+
export function createMonldingGroup(oldMG, layer, molding, catalog) {
|
|
859
|
+
var newMG = _objectSpread({}, oldMG);
|
|
876
860
|
newMG.molding = molding;
|
|
877
861
|
newMG.lines = getLinesFromItems2(oldMG, layer, catalog);
|
|
878
862
|
newMG.lines.reverse();
|