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