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