kitchen-simulator 1.1.1-test.71 → 1.1.1-test.72
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 +5 -2
- package/es/AppContext.js +6 -3
- package/es/KitchenConfigurator.js +86 -87
- package/es/KitchenConfiguratorApp.js +128 -135
- package/es/actions/area-actions.js +8 -5
- package/es/actions/export.js +24 -12
- package/es/actions/groups-actions.js +41 -27
- package/es/actions/holes-actions.js +51 -34
- package/es/actions/items-actions.js +141 -94
- package/es/actions/lines-actions.js +32 -21
- package/es/actions/project-actions.js +141 -94
- package/es/actions/scene-actions.js +17 -11
- package/es/actions/vertices-actions.js +11 -7
- package/es/actions/viewer2d-actions.js +32 -21
- package/es/actions/viewer3d-actions.js +14 -9
- package/es/catalog/areas/area/planner-element.js +5 -2
- package/es/catalog/catalog.js +17 -15
- package/es/catalog/factories/area-factory-3d.js +26 -22
- package/es/catalog/factories/area-factory.js +15 -13
- package/es/catalog/factories/export.js +10 -6
- package/es/catalog/factories/wall-factory-3d.js +36 -31
- package/es/catalog/factories/wall-factory.js +26 -21
- package/es/catalog/holes/door-closet/planner-element.js +19 -15
- package/es/catalog/holes/door-double/planner-element.js +19 -15
- package/es/catalog/holes/door-exterior/planner-element.js +20 -16
- package/es/catalog/holes/door-interior/planner-element.js +20 -16
- package/es/catalog/holes/door-panic/planner-element.js +11 -7
- package/es/catalog/holes/door-panic-double/planner-element.js +19 -15
- package/es/catalog/holes/door-sliding/planner-element.js +21 -17
- package/es/catalog/holes/doorway-framed/planner-element.js +15 -11
- package/es/catalog/holes/doorway-frameless/planner-element.js +11 -7
- package/es/catalog/holes/export.js +29 -13
- package/es/catalog/holes/window-clear/planner-element.js +14 -10
- package/es/catalog/holes/window-cross/planner-element.js +14 -10
- package/es/catalog/holes/window-double-hung/planner-element.js +14 -10
- package/es/catalog/holes/window-vertical/planner-element.js +14 -10
- package/es/catalog/lines/wall/planner-element.js +5 -2
- package/es/catalog/molding/molding-dcm/planner-element.js +9 -5
- package/es/catalog/molding/molding-fbm/planner-element.js +9 -5
- package/es/catalog/molding/molding-lrm/planner-element.js +9 -5
- package/es/catalog/properties/export.js +31 -20
- package/es/catalog/properties/property-checkbox.js +29 -28
- package/es/catalog/properties/property-color.js +19 -16
- package/es/catalog/properties/property-enum.js +27 -24
- package/es/catalog/properties/property-hidden.js +12 -9
- package/es/catalog/properties/property-lenght-measure.js +41 -38
- package/es/catalog/properties/property-length-measure.js +39 -36
- package/es/catalog/properties/property-length-measure_hole.js +41 -38
- package/es/catalog/properties/property-number.js +20 -17
- package/es/catalog/properties/property-read-only.js +19 -16
- package/es/catalog/properties/property-string.js +19 -16
- package/es/catalog/properties/property-toggle.js +19 -16
- package/es/catalog/properties/shared-property-style.js +3 -1
- package/es/catalog/utils/FuseUtils.js +13 -12
- package/es/catalog/utils/exporter.js +11 -10
- package/es/catalog/utils/geom-utils.js +24 -13
- package/es/catalog/utils/item-loader.js +92 -86
- package/es/catalog/utils/load-obj.js +24 -20
- package/es/catalog/utils/mtl-loader.js +4 -3
- package/es/catalog/utils/obj-loader.js +4 -3
- package/es/class/FuseUtils.js +13 -12
- package/es/class/area.js +24 -24
- package/es/class/export.js +36 -23
- package/es/class/group.js +55 -53
- package/es/class/guide.js +17 -15
- package/es/class/hole.js +85 -83
- package/es/class/item.js +155 -155
- package/es/class/layer.js +61 -59
- package/es/class/line.js +138 -135
- package/es/class/project.js +94 -93
- package/es/class/vertex.js +31 -29
- package/es/components/content.js +23 -19
- package/es/components/disclaimer/disclaimer.js +13 -10
- package/es/components/export.js +13 -8
- package/es/components/style/button.js +25 -25
- package/es/components/style/cancel-button.js +10 -7
- package/es/components/style/content-container.js +12 -11
- package/es/components/style/content-title.js +15 -13
- package/es/components/style/delete-button.js +12 -8
- package/es/components/style/export.js +46 -30
- package/es/components/style/form-block.js +11 -10
- package/es/components/style/form-color-input.js +10 -7
- package/es/components/style/form-label.js +11 -10
- package/es/components/style/form-number-input.js +43 -45
- package/es/components/style/form-number-input_2.js +39 -41
- package/es/components/style/form-select.js +20 -19
- package/es/components/style/form-slider.js +13 -10
- package/es/components/style/form-submit-button.js +12 -8
- package/es/components/style/form-text-input.js +28 -30
- package/es/components/viewer2d/area.js +20 -17
- package/es/components/viewer2d/export.js +46 -30
- package/es/components/viewer2d/grids/grid-horizontal-streak.js +13 -10
- package/es/components/viewer2d/grids/grid-streak.js +13 -10
- package/es/components/viewer2d/grids/grid-vertical-streak.js +13 -10
- package/es/components/viewer2d/grids/grids.js +14 -10
- package/es/components/viewer2d/group.js +19 -15
- package/es/components/viewer2d/item.js +65 -61
- package/es/components/viewer2d/layer.js +26 -23
- package/es/components/viewer2d/line.js +106 -101
- package/es/components/viewer2d/ruler.js +25 -22
- package/es/components/viewer2d/rulerDist.js +24 -21
- package/es/components/viewer2d/rulerX.js +44 -46
- package/es/components/viewer2d/rulerY.js +42 -44
- package/es/components/viewer2d/scene.js +34 -35
- package/es/components/viewer2d/snap.js +17 -13
- package/es/components/viewer2d/state.js +22 -18
- package/es/components/viewer2d/utils.js +33 -24
- package/es/components/viewer2d/vertex.js +12 -8
- package/es/components/viewer2d/viewer2d.js +159 -156
- package/es/components/viewer3d/camera-controls-module/camera-controls.module.js +19 -21
- package/es/components/viewer3d/dcm.js +3 -1
- package/es/components/viewer3d/fbm.js +3 -1
- package/es/components/viewer3d/front3D.js +16 -12
- package/es/components/viewer3d/grid-creator.js +12 -8
- package/es/components/viewer3d/grids/grid-horizontal-streak.js +9 -6
- package/es/components/viewer3d/grids/grid-streak.js +8 -5
- package/es/components/viewer3d/grids/grid-vertical-streak.js +9 -6
- package/es/components/viewer3d/libs/first-person-controls.js +5 -2
- package/es/components/viewer3d/libs/helvetiker_regular.typeface.js +3 -1
- package/es/components/viewer3d/libs/mtl-loader.js +3 -1
- package/es/components/viewer3d/libs/obj-loader.js +3 -1
- package/es/components/viewer3d/libs/orbit-controls.js +4 -2
- package/es/components/viewer3d/libs/pointer-lock-controls.js +4 -2
- package/es/components/viewer3d/lrm.js +3 -1
- package/es/components/viewer3d/model.js +3 -1
- package/es/components/viewer3d/pointer-lock-navigation.js +6 -3
- package/es/components/viewer3d/ruler-utils/itemRect.js +21 -18
- package/es/components/viewer3d/ruler-utils/layer3D.js +62 -59
- package/es/components/viewer3d/ruler-utils/ruler3D.js +43 -42
- package/es/components/viewer3d/ruler-utils/scene3D.js +13 -9
- package/es/components/viewer3d/ruler-utils/state3D.js +7 -4
- package/es/components/viewer3d/scene-creator.js +223 -197
- package/es/components/viewer3d/three-memory-cleaner.js +7 -3
- package/es/components/viewer3d/viewer3d-first-person.js +42 -42
- package/es/components/viewer3d/viewer3d.js +198 -200
- package/es/constants.js +354 -349
- package/es/index.js +11 -7
- package/es/models.js +191 -193
- package/es/plugins/SVGLoader.js +49 -48
- package/es/plugins/autosave.js +5 -3
- package/es/plugins/console-debugger.js +7 -6
- package/es/plugins/export.js +13 -8
- package/es/plugins/keyboard.js +31 -29
- package/es/reducers/areas-reducer.js +9 -7
- package/es/reducers/export.js +37 -24
- package/es/reducers/groups-reducer.js +33 -31
- package/es/reducers/holes-reducer.js +45 -43
- package/es/reducers/items-reducer.js +108 -106
- package/es/reducers/lines-reducer.js +30 -28
- package/es/reducers/project-reducer.js +107 -105
- package/es/reducers/reducer.js +19 -16
- package/es/reducers/scene-reducer.js +17 -15
- package/es/reducers/user-reducer.js +7 -5
- package/es/reducers/vertices-reducer.js +13 -11
- package/es/reducers/viewer2d-reducer.js +20 -18
- package/es/reducers/viewer3d-reducer.js +18 -16
- package/es/shared-style.js +12 -10
- package/es/styles/export.js +6 -3
- package/es/translator/en.js +3 -1
- package/es/translator/it.js +3 -1
- package/es/translator/ru.js +3 -1
- package/es/translator/translator.js +15 -13
- package/es/utils/browser.js +5 -2
- package/es/utils/convert-units-lite.js +3 -1
- package/es/utils/email-validator.js +3 -1
- package/es/utils/export.js +29 -15
- package/es/utils/geometry.js +280 -190
- package/es/utils/get-edges-of-subgraphs.js +5 -2
- package/es/utils/graph-cycles.js +7 -8
- package/es/utils/graph-inner-cycles.js +14 -10
- package/es/utils/graph.js +13 -9
- package/es/utils/helper.js +58 -41
- package/es/utils/history.js +11 -8
- package/es/utils/id-broker.js +11 -8
- package/es/utils/logger.js +3 -1
- package/es/utils/math.js +8 -5
- package/es/utils/molding.js +146 -130
- package/es/utils/name-generator.js +9 -7
- package/es/utils/objects-utils.js +14 -7
- package/es/utils/phone-validator.js +3 -1
- package/es/utils/process-black-list.js +6 -5
- package/es/utils/react-if.js +9 -7
- package/es/utils/snap-scene.js +30 -27
- package/es/utils/snap.js +57 -53
- package/es/utils/summarizeCart.js +3 -1
- package/es/utils/threeCSG.es6.js +17 -13
- package/es/version.js +3 -1
- package/package.json +1 -1
package/es/utils/geometry.js
CHANGED
|
@@ -1,11 +1,107 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
|
|
2
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.ContainsPoint = ContainsPoint;
|
|
5
|
+
exports._twoLineSegmentsIntersection = _twoLineSegmentsIntersection;
|
|
6
|
+
exports.absAngleBetweenTwoPoints = absAngleBetweenTwoPoints;
|
|
7
|
+
exports.almostEqual = void 0;
|
|
8
|
+
exports.angleBetweenTwoLines = angleBetweenTwoLines;
|
|
9
|
+
exports.angleBetweenTwoPoints = angleBetweenTwoPoints;
|
|
10
|
+
exports.angleBetweenTwoPointsAndOrigin = angleBetweenTwoPointsAndOrigin;
|
|
11
|
+
exports.buildRectFromLines = buildRectFromLines;
|
|
12
|
+
exports.calcCreateSnap = calcCreateSnap;
|
|
13
|
+
exports.calcSnap = calcSnap;
|
|
14
|
+
exports.calcSnap1 = calcSnap1;
|
|
15
|
+
exports.calcSnap2 = calcSnap2;
|
|
16
|
+
exports.calcSnap3 = calcSnap3;
|
|
17
|
+
exports.clone_point = clone_point;
|
|
18
|
+
exports.closestPointFromLine = closestPointFromLine;
|
|
19
|
+
exports.closestPointFromLineSegment = closestPointFromLineSegment;
|
|
20
|
+
exports.compareVertices = compareVertices;
|
|
21
|
+
exports.containLine = containLine;
|
|
22
|
+
exports.containPointInRect = containPointInRect;
|
|
23
|
+
exports.cosWithThreshold = cosWithThreshold;
|
|
24
|
+
exports.crossprod = crossprod;
|
|
25
|
+
exports.diff = diff;
|
|
26
|
+
exports.distancePointFromLine = distancePointFromLine;
|
|
27
|
+
exports.distancePointFromLineSegment = distancePointFromLineSegment;
|
|
28
|
+
exports.dotprod = dotprod;
|
|
29
|
+
exports.downcrossLine = downcrossLine;
|
|
30
|
+
exports.extendLine = extendLine;
|
|
31
|
+
exports.findCatalogElement = findCatalogElement;
|
|
32
|
+
exports.getAllArea = getAllArea;
|
|
33
|
+
exports.getAllAreaLines = getAllAreaLines;
|
|
34
|
+
exports.getAllCurSnap = getAllCurSnap;
|
|
35
|
+
exports.getAllHoleRect = getAllHoleRect;
|
|
36
|
+
exports.getAllItemSnap = getAllItemSnap;
|
|
37
|
+
exports.getAllItemSpecified = getAllItemSpecified;
|
|
38
|
+
exports.getAllItems = getAllItems;
|
|
39
|
+
exports.getAllLineSnap = getAllLineSnap;
|
|
40
|
+
exports.getAllLines = getAllLines;
|
|
41
|
+
exports.getCalcRectFromItem = getCalcRectFromItem;
|
|
42
|
+
exports.getCalcRectFromItem3D = getCalcRectFromItem3D;
|
|
43
|
+
exports.getCalcRectFromLine = getCalcRectFromLine;
|
|
44
|
+
exports.getCentroidOfPolygon = getCentroidOfPolygon;
|
|
45
|
+
exports.getHoleItems = getHoleItems;
|
|
46
|
+
exports.getInterSect = getInterSect;
|
|
47
|
+
exports.getLineInterSect = getLineInterSect;
|
|
48
|
+
exports.getNormaline = getNormaline;
|
|
49
|
+
exports.getRelatedLines = void 0;
|
|
50
|
+
exports.getRelatedVertices = getRelatedVertices;
|
|
51
|
+
exports.horizontalLine = horizontalLine;
|
|
52
|
+
exports.intersectRect = intersectRect;
|
|
53
|
+
exports.isBackWall = isBackWall;
|
|
54
|
+
exports.isFrontWall = isFrontWall;
|
|
55
|
+
exports.isLeftWall = isLeftWall;
|
|
56
|
+
exports.isPointInArea = isPointInArea;
|
|
57
|
+
exports.isPointInRect = isPointInRect;
|
|
58
|
+
exports.isPointOnLineSegment = isPointOnLineSegment;
|
|
59
|
+
exports.isRightWall = isRightWall;
|
|
60
|
+
exports.isSnappedLine = isSnappedLine;
|
|
61
|
+
exports.isSnappedSideLine = isSnappedSideLine;
|
|
62
|
+
exports.itemInfo = itemInfo;
|
|
63
|
+
exports.linePassingThroughTwoPoints = linePassingThroughTwoPoints;
|
|
64
|
+
exports.mapRange = mapRange;
|
|
65
|
+
exports.maxVertex = maxVertex;
|
|
66
|
+
exports.midPoint = midPoint;
|
|
67
|
+
exports.minVertex = minVertex;
|
|
68
|
+
exports.needSnap = needSnap;
|
|
69
|
+
exports.orderVertices = orderVertices;
|
|
70
|
+
exports.pointPositionOnLineSegment = pointPositionOnLineSegment;
|
|
71
|
+
exports.pointsDistance = pointsDistance;
|
|
72
|
+
exports.relationshipOfTwoOverlappedLines = relationshipOfTwoOverlappedLines;
|
|
73
|
+
exports.relationshipOfTwoOverlappedLines1 = relationshipOfTwoOverlappedLines1;
|
|
74
|
+
exports.relationshipOfTwoOverlappedLines2 = relationshipOfTwoOverlappedLines2;
|
|
75
|
+
exports.rotatePointAroundPoint = rotatePointAroundPoint;
|
|
76
|
+
exports.roundVertex = roundVertex;
|
|
77
|
+
exports.sameDistances = sameDistances;
|
|
78
|
+
exports.sameMDistances = sameMDistances;
|
|
79
|
+
exports.sameMPoints = sameMPoints;
|
|
80
|
+
exports.samePoints = samePoints;
|
|
81
|
+
exports.shrinkRect = shrinkRect;
|
|
82
|
+
exports.sinWithThreshold = sinWithThreshold;
|
|
83
|
+
exports.snapAngleByUnit = snapAngleByUnit;
|
|
84
|
+
exports.twoLineSegmentsIntersection = twoLineSegmentsIntersection;
|
|
85
|
+
exports.twoLinesIntersection = twoLinesIntersection;
|
|
86
|
+
exports.upcrossLine = upcrossLine;
|
|
87
|
+
exports.validInterSect = validInterSect;
|
|
88
|
+
exports.validSnap = validSnap;
|
|
89
|
+
exports.validateLineSnaps = validateLineSnaps;
|
|
90
|
+
exports.validateSnaps = validateSnaps;
|
|
91
|
+
exports.verticalLine = verticalLine;
|
|
92
|
+
exports.verticesDistance = verticesDistance;
|
|
93
|
+
exports.verticesMidPoint = verticesMidPoint;
|
|
94
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
|
|
95
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
|
|
96
|
+
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/createForOfIteratorHelper"));
|
|
97
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
98
|
+
var _math = require("./math.js");
|
|
99
|
+
var _constants = require("../constants");
|
|
100
|
+
var _convertUnitsLite = require("./convert-units-lite");
|
|
101
|
+
var Three = _interopRequireWildcard(require("three"));
|
|
102
|
+
var _utils = require("../components/viewer2d/utils.js");
|
|
103
|
+
var _helper = require("./helper.js");
|
|
104
|
+
var _export = require("./export.js");
|
|
9
105
|
/** @description Determines the distance between two points
|
|
10
106
|
* @param {number} x0 Vertex 0 x
|
|
11
107
|
* @param {number} y0 Vertex 0 y
|
|
@@ -13,69 +109,63 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
13
109
|
* @param {number} y1 Vertex 1 y
|
|
14
110
|
* @return {number}
|
|
15
111
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
import { convert } from "./convert-units-lite";
|
|
19
|
-
import * as Three from 'three';
|
|
20
|
-
import { returnReplaceableDeepSearchType } from "../components/viewer2d/utils.js";
|
|
21
|
-
import { isEmpty } from "./helper.js";
|
|
22
|
-
import { MathUtils } from "./export.js";
|
|
23
|
-
export function compareVertices(v0, v1) {
|
|
112
|
+
|
|
113
|
+
function compareVertices(v0, v1) {
|
|
24
114
|
return v0.x === v1.x ? v0.y - v1.y : v0.x - v1.x;
|
|
25
115
|
}
|
|
26
|
-
|
|
116
|
+
function minVertex(v0, v1) {
|
|
27
117
|
return compareVertices(v0, v1) > 0 ? v1 : v0;
|
|
28
118
|
}
|
|
29
|
-
|
|
119
|
+
function maxVertex(v0, v1) {
|
|
30
120
|
return compareVertices(v0, v1) > 0 ? v0 : v1;
|
|
31
121
|
}
|
|
32
|
-
|
|
122
|
+
function orderVertices(vertices) {
|
|
33
123
|
return vertices.sort(compareVertices);
|
|
34
124
|
}
|
|
35
|
-
|
|
125
|
+
function pointsDistance(x0, y0, x1, y1) {
|
|
36
126
|
var diff_x = x0 - x1;
|
|
37
127
|
var diff_y = y0 - y1;
|
|
38
128
|
return Math.sqrt(diff_x * diff_x + diff_y * diff_y);
|
|
39
129
|
}
|
|
40
|
-
|
|
130
|
+
function verticesDistance(v1, v2) {
|
|
41
131
|
var x0 = v1.x,
|
|
42
132
|
y0 = v1.y;
|
|
43
133
|
var x1 = v2.x,
|
|
44
134
|
y1 = v2.y;
|
|
45
135
|
return pointsDistance(x0, y0, x1, y1);
|
|
46
136
|
}
|
|
47
|
-
|
|
137
|
+
function horizontalLine(y) {
|
|
48
138
|
return {
|
|
49
139
|
a: 0,
|
|
50
140
|
b: 1,
|
|
51
141
|
c: -y
|
|
52
142
|
};
|
|
53
143
|
}
|
|
54
|
-
|
|
55
|
-
return Math.abs(x - y) < EPSILON;
|
|
144
|
+
var almostEqual = exports.almostEqual = function almostEqual(x, y) {
|
|
145
|
+
return Math.abs(x - y) < _constants.EPSILON;
|
|
56
146
|
};
|
|
57
|
-
|
|
147
|
+
function verticalLine(x) {
|
|
58
148
|
return {
|
|
59
149
|
a: 1,
|
|
60
150
|
b: 0,
|
|
61
151
|
c: -x
|
|
62
152
|
};
|
|
63
153
|
}
|
|
64
|
-
|
|
154
|
+
function upcrossLine(x, y) {
|
|
65
155
|
return {
|
|
66
156
|
a: 1,
|
|
67
157
|
b: 1,
|
|
68
158
|
c: -x - y
|
|
69
159
|
};
|
|
70
160
|
}
|
|
71
|
-
|
|
161
|
+
function downcrossLine(x, y) {
|
|
72
162
|
return {
|
|
73
163
|
a: 1,
|
|
74
164
|
b: -1,
|
|
75
165
|
c: -x + y
|
|
76
166
|
};
|
|
77
167
|
}
|
|
78
|
-
|
|
168
|
+
function linePassingThroughTwoPoints(x1, y1, x2, y2) {
|
|
79
169
|
if (x1 === x2 && y1 == y2) throw new Error('Geometry error');
|
|
80
170
|
//if (x1 === x2) return verticalLine(x1);
|
|
81
171
|
//if (y1 === y2) return horizontalLine(y1);
|
|
@@ -86,18 +176,18 @@ export function linePassingThroughTwoPoints(x1, y1, x2, y2) {
|
|
|
86
176
|
c: y2 * x1 - x2 * y1
|
|
87
177
|
};
|
|
88
178
|
}
|
|
89
|
-
|
|
179
|
+
function getNormaline(x1, y1, x2, y2) {
|
|
90
180
|
var lineFunction = linePassingThroughTwoPoints(x1, y1, x2, y2);
|
|
91
181
|
return {
|
|
92
182
|
x: lineFunction.a / Math.sqrt(lineFunction.a * lineFunction.a + lineFunction.b * lineFunction.b),
|
|
93
183
|
y: lineFunction.b / Math.sqrt(lineFunction.a * lineFunction.a + lineFunction.b * lineFunction.b)
|
|
94
184
|
};
|
|
95
185
|
}
|
|
96
|
-
|
|
186
|
+
function distancePointFromLine(a, b, c, x, y) {
|
|
97
187
|
//https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line
|
|
98
|
-
return fAbs(a * x + b * y + c) / Math.sqrt(a * a + b * b);
|
|
188
|
+
return (0, _math.fAbs)(a * x + b * y + c) / Math.sqrt(a * a + b * b);
|
|
99
189
|
}
|
|
100
|
-
|
|
190
|
+
function closestPointFromLine(a, b, c, x, y) {
|
|
101
191
|
//https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line
|
|
102
192
|
var denom = a * a + b * b;
|
|
103
193
|
return {
|
|
@@ -115,7 +205,7 @@ export function closestPointFromLine(a, b, c, x, y) {
|
|
|
115
205
|
* @param {number} l costant of second line
|
|
116
206
|
* @return {object} {x,y} point's coordinates
|
|
117
207
|
*/
|
|
118
|
-
|
|
208
|
+
function twoLinesIntersection(a, b, c, j, k, l) {
|
|
119
209
|
var angularCoefficientsDiff = b * j - a * k;
|
|
120
210
|
if (angularCoefficientsDiff === 0) return undefined; //no intersection
|
|
121
211
|
|
|
@@ -126,10 +216,10 @@ export function twoLinesIntersection(a, b, c, j, k, l) {
|
|
|
126
216
|
y: y
|
|
127
217
|
};
|
|
128
218
|
}
|
|
129
|
-
|
|
219
|
+
function twoLineSegmentsIntersection(p1, p2, p3, p4) {
|
|
130
220
|
return _twoLineSegmentsIntersection(p1, p2, p3.toJS(), p4.toJS());
|
|
131
221
|
}
|
|
132
|
-
|
|
222
|
+
function _twoLineSegmentsIntersection(p1, p2, p3, p4) {
|
|
133
223
|
//https://github.com/psalaets/line-intersect/blob/master/lib/check-intersection.js
|
|
134
224
|
|
|
135
225
|
var x1 = p1.x,
|
|
@@ -143,8 +233,8 @@ export function _twoLineSegmentsIntersection(p1, p2, p3, p4) {
|
|
|
143
233
|
var denom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);
|
|
144
234
|
var numA = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3);
|
|
145
235
|
var numB = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3);
|
|
146
|
-
if (fAbs(denom) <= EPSILON) {
|
|
147
|
-
if (fAbs(numA) <= EPSILON && fAbs(numB) <= EPSILON) {
|
|
236
|
+
if ((0, _math.fAbs)(denom) <= _constants.EPSILON) {
|
|
237
|
+
if ((0, _math.fAbs)(numA) <= _constants.EPSILON && (0, _math.fAbs)(numB) <= _constants.EPSILON) {
|
|
148
238
|
var comparator = function comparator(pa, pb) {
|
|
149
239
|
return pa.x === pb.x ? pa.y - pb.y : pa.x - pb.x;
|
|
150
240
|
};
|
|
@@ -153,7 +243,7 @@ export function _twoLineSegmentsIntersection(p1, p2, p3, p4) {
|
|
|
153
243
|
var _sort = [line0, line1].sort(function (lineA, lineB) {
|
|
154
244
|
return comparator(lineA[0], lineB[0]);
|
|
155
245
|
}),
|
|
156
|
-
_sort2 =
|
|
246
|
+
_sort2 = (0, _slicedToArray2["default"])(_sort, 2),
|
|
157
247
|
lineSX = _sort2[0],
|
|
158
248
|
lineDX = _sort2[1];
|
|
159
249
|
comparator(lineSX[1], lineDX[0]) < 0 ? 'colinear' : 'none';
|
|
@@ -173,7 +263,7 @@ export function _twoLineSegmentsIntersection(p1, p2, p3, p4) {
|
|
|
173
263
|
}
|
|
174
264
|
var uA = numA / denom;
|
|
175
265
|
var uB = numB / denom;
|
|
176
|
-
if (uA >= 0 - EPSILON && uA <= 1 + EPSILON && uB >= 0 - EPSILON && uB <= 1 + EPSILON) {
|
|
266
|
+
if (uA >= 0 - _constants.EPSILON && uA <= 1 + _constants.EPSILON && uB >= 0 - _constants.EPSILON && uB <= 1 + _constants.EPSILON) {
|
|
177
267
|
var _point = {
|
|
178
268
|
x: x1 + uA * (x2 - x1),
|
|
179
269
|
y: y1 + uA * (y2 - y1)
|
|
@@ -187,7 +277,7 @@ export function _twoLineSegmentsIntersection(p1, p2, p3, p4) {
|
|
|
187
277
|
type: 'none'
|
|
188
278
|
};
|
|
189
279
|
}
|
|
190
|
-
|
|
280
|
+
function distancePointFromLineSegment(v1, v2, xp, yp) {
|
|
191
281
|
//http://stackoverflow.com/a/6853926/1398836
|
|
192
282
|
var x1 = v1.x,
|
|
193
283
|
y1 = v1.y;
|
|
@@ -230,8 +320,8 @@ export function distancePointFromLineSegment(v1, v2, xp, yp) {
|
|
|
230
320
|
* @param maxDistance {number} the epsilon value used for comparisons
|
|
231
321
|
* @returns {boolean} true if the point lies on the line segment false otherwise
|
|
232
322
|
*/
|
|
233
|
-
|
|
234
|
-
var maxDistance = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : EPSILON;
|
|
323
|
+
function isPointOnLineSegment(x1, y1, x2, y2, xp, yp) {
|
|
324
|
+
var maxDistance = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : _constants.EPSILON;
|
|
235
325
|
return distancePointFromLineSegment({
|
|
236
326
|
x: x1,
|
|
237
327
|
y: y1
|
|
@@ -240,7 +330,7 @@ export function isPointOnLineSegment(x1, y1, x2, y2, xp, yp) {
|
|
|
240
330
|
y: y2
|
|
241
331
|
}, xp, yp) <= maxDistance;
|
|
242
332
|
}
|
|
243
|
-
|
|
333
|
+
function closestPointFromLineSegment(x1, y1, x2, y2, xp, yp) {
|
|
244
334
|
if (x1 === x2) return {
|
|
245
335
|
x: x1,
|
|
246
336
|
y: yp
|
|
@@ -260,7 +350,7 @@ export function closestPointFromLineSegment(x1, y1, x2, y2, xp, yp) {
|
|
|
260
350
|
y: y
|
|
261
351
|
};
|
|
262
352
|
}
|
|
263
|
-
|
|
353
|
+
function pointPositionOnLineSegment(x1, y1, x2, y2, xp, yp) {
|
|
264
354
|
var length = pointsDistance(x1, y1, x2, y2);
|
|
265
355
|
var distance = pointsDistance(x1, y1, xp, yp);
|
|
266
356
|
var offset = distance / length;
|
|
@@ -270,16 +360,16 @@ export function pointPositionOnLineSegment(x1, y1, x2, y2, xp, yp) {
|
|
|
270
360
|
*/
|
|
271
361
|
return offset;
|
|
272
362
|
}
|
|
273
|
-
|
|
363
|
+
function mapRange(value, low1, high1, low2, high2) {
|
|
274
364
|
return low2 + (high2 - low2) * (value - low1) / (high1 - low1);
|
|
275
365
|
}
|
|
276
|
-
|
|
366
|
+
function angleBetweenTwoPointsAndOrigin(x1, y1, x2, y2) {
|
|
277
367
|
return -Math.atan2(y1 - y2, x2 - x1) * 180 / Math.PI;
|
|
278
368
|
}
|
|
279
|
-
|
|
369
|
+
function angleBetweenTwoPoints(x1, y1, x2, y2) {
|
|
280
370
|
return Math.atan2(y2 - y1, x2 - x1);
|
|
281
371
|
}
|
|
282
|
-
|
|
372
|
+
function angleBetweenTwoLines(line, drawingLine, vertices) {
|
|
283
373
|
var points = [];
|
|
284
374
|
|
|
285
375
|
// safety guards
|
|
@@ -287,7 +377,7 @@ export function angleBetweenTwoLines(line, drawingLine, vertices) {
|
|
|
287
377
|
var dv = Array.isArray(drawingLine === null || drawingLine === void 0 ? void 0 : drawingLine.vertices) ? drawingLine.vertices : [];
|
|
288
378
|
|
|
289
379
|
// 1) push common vertices (in order of line.vertices)
|
|
290
|
-
var _iterator =
|
|
380
|
+
var _iterator = (0, _createForOfIteratorHelper2["default"])(lv),
|
|
291
381
|
_step;
|
|
292
382
|
try {
|
|
293
383
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -301,7 +391,7 @@ export function angleBetweenTwoLines(line, drawingLine, vertices) {
|
|
|
301
391
|
} finally {
|
|
302
392
|
_iterator.f();
|
|
303
393
|
}
|
|
304
|
-
var _iterator2 =
|
|
394
|
+
var _iterator2 = (0, _createForOfIteratorHelper2["default"])(lv),
|
|
305
395
|
_step2;
|
|
306
396
|
try {
|
|
307
397
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
@@ -315,7 +405,7 @@ export function angleBetweenTwoLines(line, drawingLine, vertices) {
|
|
|
315
405
|
} finally {
|
|
316
406
|
_iterator2.f();
|
|
317
407
|
}
|
|
318
|
-
var _iterator3 =
|
|
408
|
+
var _iterator3 = (0, _createForOfIteratorHelper2["default"])(dv),
|
|
319
409
|
_step3;
|
|
320
410
|
try {
|
|
321
411
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
@@ -337,7 +427,7 @@ export function angleBetweenTwoLines(line, drawingLine, vertices) {
|
|
|
337
427
|
var v = vertices === null || vertices === void 0 ? void 0 : vertices[idx];
|
|
338
428
|
return v ? new Three.Vector2(v.x, v.y) : new Three.Vector2(0, 0);
|
|
339
429
|
}),
|
|
340
|
-
_points$slice$map2 =
|
|
430
|
+
_points$slice$map2 = (0, _slicedToArray2["default"])(_points$slice$map, 3),
|
|
341
431
|
c = _points$slice$map2[0],
|
|
342
432
|
p1 = _points$slice$map2[1],
|
|
343
433
|
p2 = _points$slice$map2[2];
|
|
@@ -345,23 +435,23 @@ export function angleBetweenTwoLines(line, drawingLine, vertices) {
|
|
|
345
435
|
var vec2 = p2.clone().sub(c).normalize();
|
|
346
436
|
return Math.floor(vec1.angle() * 180 / Math.PI - vec2.angle() * 180 / Math.PI + 0.5);
|
|
347
437
|
}
|
|
348
|
-
|
|
438
|
+
var getRelatedLines = exports.getRelatedLines = function getRelatedLines(tlines, drawingLine, vertices, lines) {
|
|
349
439
|
var exceptLineId = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
|
|
350
440
|
if (!(drawingLine !== null && drawingLine !== void 0 && drawingLine.vertices) || !Array.isArray(drawingLine.vertices)) return;
|
|
351
441
|
var seen = new Set();
|
|
352
|
-
var _iterator4 =
|
|
442
|
+
var _iterator4 = (0, _createForOfIteratorHelper2["default"])(drawingLine.vertices),
|
|
353
443
|
_step4;
|
|
354
444
|
try {
|
|
355
445
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
356
446
|
var vIdx = _step4.value;
|
|
357
447
|
var vertex = vertices === null || vertices === void 0 ? void 0 : vertices[vIdx];
|
|
358
448
|
if (!(vertex !== null && vertex !== void 0 && vertex.lines)) continue;
|
|
359
|
-
var _iterator5 =
|
|
449
|
+
var _iterator5 = (0, _createForOfIteratorHelper2["default"])(vertex.lines),
|
|
360
450
|
_step5;
|
|
361
451
|
try {
|
|
362
452
|
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
363
453
|
var lineId = _step5.value;
|
|
364
|
-
if (lineId !== drawingLine.id && lineId !== exceptLineId && !isEmpty(lines === null || lines === void 0 ? void 0 : lines[lineId]) && !seen.has(lineId)) {
|
|
454
|
+
if (lineId !== drawingLine.id && lineId !== exceptLineId && !(0, _helper.isEmpty)(lines === null || lines === void 0 ? void 0 : lines[lineId]) && !seen.has(lineId)) {
|
|
365
455
|
seen.add(lineId);
|
|
366
456
|
tlines.push(lines[lineId]);
|
|
367
457
|
}
|
|
@@ -378,12 +468,12 @@ export var getRelatedLines = function getRelatedLines(tlines, drawingLine, verti
|
|
|
378
468
|
_iterator4.f();
|
|
379
469
|
}
|
|
380
470
|
};
|
|
381
|
-
|
|
471
|
+
function snapAngleByUnit(lineAngle, vertices, drawingLine, x, y, dragVertexId) {
|
|
382
472
|
var tx, ty;
|
|
383
473
|
var absAngle = Math.abs(lineAngle);
|
|
384
474
|
// angle snapping as a value of UNIT_ANGLE
|
|
385
|
-
var rest = absAngle % UNIT_ANGLE;
|
|
386
|
-
var missAngle = UNIT_ANGLE - rest;
|
|
475
|
+
var rest = absAngle % _constants.UNIT_ANGLE;
|
|
476
|
+
var missAngle = _constants.UNIT_ANGLE - rest;
|
|
387
477
|
// the origin point of rotation(snapping)
|
|
388
478
|
var originVerId = drawingLine.vertices.findIndex(function (vertice) {
|
|
389
479
|
return vertice !== dragVertexId;
|
|
@@ -392,7 +482,7 @@ export function snapAngleByUnit(lineAngle, vertices, drawingLine, x, y, dragVert
|
|
|
392
482
|
var ox = vertices[originVerId].x;
|
|
393
483
|
var oy = vertices[originVerId].y;
|
|
394
484
|
// check whether the line is snapped to before point.
|
|
395
|
-
if (rest <= UNIT_ANGLE / 2) {
|
|
485
|
+
if (rest <= _constants.UNIT_ANGLE / 2) {
|
|
396
486
|
// determine the direction of rotation.
|
|
397
487
|
rest = lineAngle > 0 ? rest : -rest;
|
|
398
488
|
// rotate the current point to last point around the first point of drawing line.
|
|
@@ -400,7 +490,7 @@ export function snapAngleByUnit(lineAngle, vertices, drawingLine, x, y, dragVert
|
|
|
400
490
|
ty = rotatePointAroundPoint(x, y, ox, oy, rest).y;
|
|
401
491
|
}
|
|
402
492
|
// check whether the line is snapped to next new point.
|
|
403
|
-
else if (rest > UNIT_ANGLE / 2) {
|
|
493
|
+
else if (rest > _constants.UNIT_ANGLE / 2) {
|
|
404
494
|
// determine the direction of rotation.
|
|
405
495
|
missAngle = lineAngle > 0 ? -missAngle : missAngle;
|
|
406
496
|
// rotate the current point to last point around the first point of drawing line.
|
|
@@ -413,30 +503,30 @@ export function snapAngleByUnit(lineAngle, vertices, drawingLine, x, y, dragVert
|
|
|
413
503
|
};
|
|
414
504
|
return resPoint;
|
|
415
505
|
}
|
|
416
|
-
|
|
506
|
+
function absAngleBetweenTwoPoints(x1, y1, x2, y2) {
|
|
417
507
|
return Math.atan2(y2 - y1, Math.abs(x2 - x1));
|
|
418
508
|
}
|
|
419
|
-
|
|
509
|
+
function samePoints(_ref, _ref2) {
|
|
420
510
|
var x1 = _ref.x,
|
|
421
511
|
y1 = _ref.y;
|
|
422
512
|
var x2 = _ref2.x,
|
|
423
513
|
y2 = _ref2.y;
|
|
424
|
-
return fAbs(x1 - x2) <= EPSILON && fAbs(y1 - y2) <= EPSILON;
|
|
514
|
+
return (0, _math.fAbs)(x1 - x2) <= _constants.EPSILON && (0, _math.fAbs)(y1 - y2) <= _constants.EPSILON;
|
|
425
515
|
}
|
|
426
|
-
|
|
427
|
-
return fAbs(dis1 - dis2) <= EPSILON;
|
|
516
|
+
function sameDistances(dis1, dis2) {
|
|
517
|
+
return (0, _math.fAbs)(dis1 - dis2) <= _constants.EPSILON;
|
|
428
518
|
}
|
|
429
|
-
|
|
519
|
+
function sameMPoints(_ref3, _ref4) {
|
|
430
520
|
var x1 = _ref3.x,
|
|
431
521
|
y1 = _ref3.y;
|
|
432
522
|
var x2 = _ref4.x,
|
|
433
523
|
y2 = _ref4.y;
|
|
434
|
-
return fAbs(x1 - x2) <= MEPSILON && fAbs(y1 - y2) <= MEPSILON;
|
|
524
|
+
return (0, _math.fAbs)(x1 - x2) <= _constants.MEPSILON && (0, _math.fAbs)(y1 - y2) <= _constants.MEPSILON;
|
|
435
525
|
}
|
|
436
|
-
|
|
437
|
-
return fAbs(dis1 - dis2) <= MEPSILON;
|
|
526
|
+
function sameMDistances(dis1, dis2) {
|
|
527
|
+
return (0, _math.fAbs)(dis1 - dis2) <= _constants.MEPSILON;
|
|
438
528
|
}
|
|
439
|
-
|
|
529
|
+
function isPointInRect(rect, point) {
|
|
440
530
|
var result = true;
|
|
441
531
|
for (var i = 0; i < rect.length; i++) {
|
|
442
532
|
var pos1 = rect[i];
|
|
@@ -456,23 +546,23 @@ export function isPointInRect(rect, point) {
|
|
|
456
546
|
* @param {number} newDistance New line length
|
|
457
547
|
* @return {object}
|
|
458
548
|
*/
|
|
459
|
-
|
|
549
|
+
function extendLine(x1, y1, x2, y2, newDistance) {
|
|
460
550
|
var precision = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 6;
|
|
461
551
|
var rad = angleBetweenTwoPoints(x1, y1, x2, y2);
|
|
462
552
|
return {
|
|
463
|
-
x: toFixedFloat(x1 + Math.cos(rad) * newDistance, precision),
|
|
464
|
-
y: toFixedFloat(y1 + Math.sin(rad) * newDistance, precision)
|
|
553
|
+
x: (0, _math.toFixedFloat)(x1 + Math.cos(rad) * newDistance, precision),
|
|
554
|
+
y: (0, _math.toFixedFloat)(y1 + Math.sin(rad) * newDistance, precision)
|
|
465
555
|
};
|
|
466
556
|
}
|
|
467
|
-
|
|
557
|
+
function roundVertex(vertex) {
|
|
468
558
|
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 6;
|
|
469
|
-
vertex.set('x', toFixedFloat(vertex.get('x'), precision));
|
|
470
|
-
vertex.set('y', toFixedFloat(vertex.get('y'), precision));
|
|
559
|
+
vertex.set('x', (0, _math.toFixedFloat)(vertex.get('x'), precision));
|
|
560
|
+
vertex.set('y', (0, _math.toFixedFloat)(vertex.get('y'), precision));
|
|
471
561
|
return vertex;
|
|
472
562
|
}
|
|
473
563
|
|
|
474
564
|
//https://github.com/MartyWallace/PolyK
|
|
475
|
-
|
|
565
|
+
function ContainsPoint(polygon, pointX, pointY) {
|
|
476
566
|
var n = polygon.length >> 1;
|
|
477
567
|
var ax, lup;
|
|
478
568
|
var ay = polygon[2 * n - 3] - pointY;
|
|
@@ -511,21 +601,21 @@ export function ContainsPoint(polygon, pointX, pointY) {
|
|
|
511
601
|
}
|
|
512
602
|
return (depth & 1) === 1;
|
|
513
603
|
}
|
|
514
|
-
|
|
604
|
+
function cosWithThreshold(alpha, threshold) {
|
|
515
605
|
var cos = Math.cos(alpha);
|
|
516
606
|
return cos < threshold ? 0 : cos;
|
|
517
607
|
}
|
|
518
|
-
|
|
608
|
+
function sinWithThreshold(alpha, threshold) {
|
|
519
609
|
var sin = Math.sin(alpha);
|
|
520
610
|
return sin < threshold ? 0 : sin;
|
|
521
611
|
}
|
|
522
|
-
|
|
612
|
+
function midPoint(x1, y1, x2, y2) {
|
|
523
613
|
return {
|
|
524
614
|
x: (x1 + x2) / 2,
|
|
525
615
|
y: (y1 + y2) / 2
|
|
526
616
|
};
|
|
527
617
|
}
|
|
528
|
-
|
|
618
|
+
function verticesMidPoint(verticesArray) {
|
|
529
619
|
var res = verticesArray.reduce(function (incr, vertex) {
|
|
530
620
|
return {
|
|
531
621
|
x: incr.x + vertex.x,
|
|
@@ -540,7 +630,7 @@ export function verticesMidPoint(verticesArray) {
|
|
|
540
630
|
y: res.y / verticesArray.length
|
|
541
631
|
};
|
|
542
632
|
}
|
|
543
|
-
|
|
633
|
+
function rotatePointAroundPoint(px, py, ox, oy, theta) {
|
|
544
634
|
var thetaRad = theta * Math.PI / 180;
|
|
545
635
|
var cos = Math.cos(thetaRad);
|
|
546
636
|
var sin = Math.sin(thetaRad);
|
|
@@ -574,7 +664,7 @@ function itemrectInfo(x, y, rotRad, size, layoutpos, is_corner) {
|
|
|
574
664
|
is_corner: is_corner
|
|
575
665
|
};
|
|
576
666
|
}
|
|
577
|
-
|
|
667
|
+
function getCalcRectFromItem(item) {
|
|
578
668
|
var itemInfo;
|
|
579
669
|
if (item === undefined) itemInfo = [];else itemInfo = item.item;
|
|
580
670
|
var x = item.pos.x;
|
|
@@ -602,7 +692,7 @@ export function getCalcRectFromItem(item) {
|
|
|
602
692
|
itemInfo: itemInfo
|
|
603
693
|
};
|
|
604
694
|
}
|
|
605
|
-
|
|
695
|
+
function getCalcRectFromItem3D(item) {
|
|
606
696
|
var itemInfo;
|
|
607
697
|
if (item === undefined) itemInfo = [];else itemInfo = item.item;
|
|
608
698
|
var x = item.pos.x;
|
|
@@ -630,7 +720,7 @@ export function getCalcRectFromItem3D(item) {
|
|
|
630
720
|
itemInfo: itemInfo
|
|
631
721
|
};
|
|
632
722
|
}
|
|
633
|
-
|
|
723
|
+
function getAllItems(scene, catalog, allLineRects) {
|
|
634
724
|
var layerID = scene.selectedLayer;
|
|
635
725
|
var layer = scene.layers.get(layerID);
|
|
636
726
|
var curiteminfo;
|
|
@@ -642,7 +732,7 @@ export function getAllItems(scene, catalog, allLineRects) {
|
|
|
642
732
|
selectedItem = layer.getIn(['items', layer.selected.items.get(0)]);
|
|
643
733
|
var catid = selectedItem.type;
|
|
644
734
|
var cat = catalog.elements[catid];
|
|
645
|
-
if (!cat) cat = catalog.elements[returnReplaceableDeepSearchType(catid)];
|
|
735
|
+
if (!cat) cat = catalog.elements[(0, _utils.returnReplaceableDeepSearchType)(catid)];
|
|
646
736
|
currentItem = {
|
|
647
737
|
selectedItem: selectedItem,
|
|
648
738
|
cat: cat
|
|
@@ -659,7 +749,7 @@ export function getAllItems(scene, catalog, allLineRects) {
|
|
|
659
749
|
var catid = item.type;
|
|
660
750
|
var cat = catalog.elements[catid];
|
|
661
751
|
if (!cat) {
|
|
662
|
-
cat = catalog.elements[returnReplaceableDeepSearchType(catid)];
|
|
752
|
+
cat = catalog.elements[(0, _utils.returnReplaceableDeepSearchType)(catid)];
|
|
663
753
|
}
|
|
664
754
|
var sizeinfo = [];
|
|
665
755
|
var width, height, depth;
|
|
@@ -671,13 +761,13 @@ export function getAllItems(scene, catalog, allLineRects) {
|
|
|
671
761
|
heightUnit: item.properties.get('height').get('_unit'),
|
|
672
762
|
depthUnit: item.properties.get('depth').get('_unit')
|
|
673
763
|
};
|
|
674
|
-
sizeinfo =
|
|
764
|
+
sizeinfo = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, sizeinfo), {}, {
|
|
675
765
|
layoutpos: cat && cat.info.layoutpos,
|
|
676
766
|
is_corner: cat && cat.info.is_corner
|
|
677
767
|
});
|
|
678
|
-
width = convert(sizeinfo.width).from(sizeinfo.widthUnit).to(scene.unit);
|
|
679
|
-
height = convert(sizeinfo.depth).from(sizeinfo.depthUnit).to(scene.unit);
|
|
680
|
-
depth = convert(sizeinfo.height).from(sizeinfo.heightUnit).to(scene.unit);
|
|
768
|
+
width = (0, _convertUnitsLite.convert)(sizeinfo.width).from(sizeinfo.widthUnit).to(scene.unit);
|
|
769
|
+
height = (0, _convertUnitsLite.convert)(sizeinfo.depth).from(sizeinfo.depthUnit).to(scene.unit);
|
|
770
|
+
depth = (0, _convertUnitsLite.convert)(sizeinfo.height).from(sizeinfo.heightUnit).to(scene.unit);
|
|
681
771
|
val.size = {
|
|
682
772
|
width: width,
|
|
683
773
|
height: height,
|
|
@@ -710,7 +800,7 @@ export function getAllItems(scene, catalog, allLineRects) {
|
|
|
710
800
|
otherItems: otherItems
|
|
711
801
|
};
|
|
712
802
|
}
|
|
713
|
-
|
|
803
|
+
function getAllItemSpecified(scene, catalog, filter) {
|
|
714
804
|
var _scene$layers, _scene$layers$get;
|
|
715
805
|
var layerID = scene === null || scene === void 0 ? void 0 : scene.selectedLayer;
|
|
716
806
|
var layer = scene === null || scene === void 0 || (_scene$layers = scene.layers) === null || _scene$layers === void 0 || (_scene$layers$get = _scene$layers.get) === null || _scene$layers$get === void 0 ? void 0 : _scene$layers$get.call(_scene$layers, layerID);
|
|
@@ -736,7 +826,7 @@ export function getAllItemSpecified(scene, catalog, filter) {
|
|
|
736
826
|
var getSize = function getSize(key) {
|
|
737
827
|
var _props$getIn;
|
|
738
828
|
var length = props === null || props === void 0 || (_props$getIn = props.getIn) === null || _props$getIn === void 0 ? void 0 : _props$getIn.call(props, [key, '_length']);
|
|
739
|
-
return length != null ? convert(length).from('in').to(scene.unit) : 0;
|
|
829
|
+
return length != null ? (0, _convertUnitsLite.convert)(length).from('in').to(scene.unit) : 0;
|
|
740
830
|
};
|
|
741
831
|
val.size = {
|
|
742
832
|
width: getSize('width'),
|
|
@@ -769,13 +859,13 @@ export function getAllItemSpecified(scene, catalog, filter) {
|
|
|
769
859
|
others: iteminfo
|
|
770
860
|
};
|
|
771
861
|
}
|
|
772
|
-
|
|
862
|
+
function findCatalogElement(catalog, elementName) {
|
|
773
863
|
if (!elementName || !catalog) return null;
|
|
774
864
|
var variants = [elementName, elementName.toLowerCase()];
|
|
775
865
|
var deepVariants = variants.map(function (v) {
|
|
776
|
-
return returnReplaceableDeepSearchType(v);
|
|
866
|
+
return (0, _utils.returnReplaceableDeepSearchType)(v);
|
|
777
867
|
}).filter(Boolean);
|
|
778
|
-
var allCandidates = [].concat(variants,
|
|
868
|
+
var allCandidates = [].concat(variants, (0, _toConsumableArray2["default"])(deepVariants));
|
|
779
869
|
var getElement = function getElement(catid) {
|
|
780
870
|
if (!catid) return null;
|
|
781
871
|
|
|
@@ -790,7 +880,7 @@ export function findCatalogElement(catalog, elementName) {
|
|
|
790
880
|
}
|
|
791
881
|
return null;
|
|
792
882
|
};
|
|
793
|
-
var _iterator6 =
|
|
883
|
+
var _iterator6 = (0, _createForOfIteratorHelper2["default"])(allCandidates),
|
|
794
884
|
_step6;
|
|
795
885
|
try {
|
|
796
886
|
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
@@ -805,7 +895,7 @@ export function findCatalogElement(catalog, elementName) {
|
|
|
805
895
|
}
|
|
806
896
|
return null;
|
|
807
897
|
}
|
|
808
|
-
|
|
898
|
+
function isSnappedLine(calcrect, allLineRects) {
|
|
809
899
|
if (allLineRects === undefined) return false;
|
|
810
900
|
var r2 = calcrect.rect[2];
|
|
811
901
|
var r3 = calcrect.rect[3];
|
|
@@ -813,18 +903,18 @@ export function isSnappedLine(calcrect, allLineRects) {
|
|
|
813
903
|
var l2 = linerect.rect[2];
|
|
814
904
|
var l3 = linerect.rect[3];
|
|
815
905
|
var delta = verticesDistance(l2, r3) + verticesDistance(r3, r2) + verticesDistance(r2, l3) - verticesDistance(l3, l2);
|
|
816
|
-
if (delta < EPSILON) {
|
|
906
|
+
if (delta < _constants.EPSILON) {
|
|
817
907
|
return true;
|
|
818
908
|
} else {
|
|
819
909
|
l2 = linerect.rect[3];
|
|
820
910
|
l3 = linerect.rect[2];
|
|
821
911
|
delta = verticesDistance(l2, r3) + verticesDistance(r3, r2) + verticesDistance(r2, l3) - verticesDistance(l3, l2);
|
|
822
|
-
return delta < EPSILON;
|
|
912
|
+
return delta < _constants.EPSILON;
|
|
823
913
|
}
|
|
824
914
|
});
|
|
825
915
|
return result;
|
|
826
916
|
}
|
|
827
|
-
|
|
917
|
+
function isSnappedSideLine(calcrect, allLineRects) {
|
|
828
918
|
if (allLineRects === undefined) return 0;
|
|
829
919
|
var r2 = calcrect.rect[1];
|
|
830
920
|
var r3 = calcrect.rect[2];
|
|
@@ -832,13 +922,13 @@ export function isSnappedSideLine(calcrect, allLineRects) {
|
|
|
832
922
|
var l2 = linerect.rect[2];
|
|
833
923
|
var l3 = linerect.rect[3];
|
|
834
924
|
var delta = verticesDistance(l2, r3) + verticesDistance(r3, r2) + verticesDistance(r2, l3) - verticesDistance(l3, l2);
|
|
835
|
-
return delta < EPSILON;
|
|
925
|
+
return delta < _constants.EPSILON;
|
|
836
926
|
});
|
|
837
927
|
return result;
|
|
838
928
|
}
|
|
839
929
|
|
|
840
930
|
/** Calculate candidate positions */
|
|
841
|
-
|
|
931
|
+
function getAllItemSnap(allItemRects) {
|
|
842
932
|
var allItemSnap = [];
|
|
843
933
|
var cur = allItemRects.cur;
|
|
844
934
|
|
|
@@ -904,7 +994,7 @@ export function getAllItemSnap(allItemRects) {
|
|
|
904
994
|
});
|
|
905
995
|
return allItemSnap;
|
|
906
996
|
}
|
|
907
|
-
|
|
997
|
+
function getAllArea(layer) {
|
|
908
998
|
var allAreaLines = [];
|
|
909
999
|
var allLines = [];
|
|
910
1000
|
var verticesArray = [];
|
|
@@ -931,11 +1021,11 @@ export function getAllArea(layer) {
|
|
|
931
1021
|
}
|
|
932
1022
|
|
|
933
1023
|
/** Get all lines of the scene */
|
|
934
|
-
|
|
1024
|
+
function getAllLines(layer) {
|
|
935
1025
|
var allAreaLines = getAllAreaLines(layer);
|
|
936
1026
|
var allLines = [];
|
|
937
1027
|
//let allNonAreaLines = [];
|
|
938
|
-
var thick = LINE_THICKNESS / 2;
|
|
1028
|
+
var thick = _constants.LINE_THICKNESS / 2;
|
|
939
1029
|
layer.lines.forEach(function (line) {
|
|
940
1030
|
var i = containLine(allAreaLines, line);
|
|
941
1031
|
// let thick = line.properties.getIn(['thickness', 'length']);
|
|
@@ -989,7 +1079,7 @@ export function getAllLines(layer) {
|
|
|
989
1079
|
}
|
|
990
1080
|
|
|
991
1081
|
/** Get lines that wraps the area */
|
|
992
|
-
|
|
1082
|
+
function getAllAreaLines(layer) {
|
|
993
1083
|
var areainfo = [];
|
|
994
1084
|
layer.areas.forEach(function (area) {
|
|
995
1085
|
var sz = area.vertices.size;
|
|
@@ -999,7 +1089,7 @@ export function getAllAreaLines(layer) {
|
|
|
999
1089
|
});
|
|
1000
1090
|
return areainfo;
|
|
1001
1091
|
}
|
|
1002
|
-
|
|
1092
|
+
function containLine(lines, line) {
|
|
1003
1093
|
// lines: [array]
|
|
1004
1094
|
var sz = lines.length;
|
|
1005
1095
|
for (var i = 0; i < sz; i++) {
|
|
@@ -1010,7 +1100,7 @@ export function containLine(lines, line) {
|
|
|
1010
1100
|
}
|
|
1011
1101
|
return -1;
|
|
1012
1102
|
}
|
|
1013
|
-
|
|
1103
|
+
function buildRectFromLines(layer, lines) {
|
|
1014
1104
|
var rect = [];
|
|
1015
1105
|
lines.forEach(function (line) {
|
|
1016
1106
|
var vxys = []; // 0: x0, 1: y0, 2: x1, 3: y1
|
|
@@ -1028,7 +1118,7 @@ export function buildRectFromLines(layer, lines) {
|
|
|
1028
1118
|
});
|
|
1029
1119
|
return rect;
|
|
1030
1120
|
}
|
|
1031
|
-
|
|
1121
|
+
function getRelatedVertices(x0, y0, x1, y1, layer) {
|
|
1032
1122
|
var verticesArray = [];
|
|
1033
1123
|
var mapVertIDtoIndex = {};
|
|
1034
1124
|
layer.vertices.forEach(function (vertex) {
|
|
@@ -1048,7 +1138,7 @@ export function getRelatedVertices(x0, y0, x1, y1, layer) {
|
|
|
1048
1138
|
x: verticesArray[mapVertIDtoIndex[vertID1]][0],
|
|
1049
1139
|
y: verticesArray[mapVertIDtoIndex[vertID1]][1]
|
|
1050
1140
|
};
|
|
1051
|
-
if (Math.abs(pt0.x - x0) < EPSILON && Math.abs(pt0.y - y0) < EPSILON && Math.abs(pt1.x - x1) < EPSILON && Math.abs(pt1.y - y1) < EPSILON || Math.abs(pt0.x - x1) < EPSILON && Math.abs(pt0.y - y1) < EPSILON && Math.abs(pt1.x - x0) < EPSILON && Math.abs(pt1.y - y0) < EPSILON) {
|
|
1141
|
+
if (Math.abs(pt0.x - x0) < _constants.EPSILON && Math.abs(pt0.y - y0) < _constants.EPSILON && Math.abs(pt1.x - x1) < _constants.EPSILON && Math.abs(pt1.y - y1) < _constants.EPSILON || Math.abs(pt0.x - x1) < _constants.EPSILON && Math.abs(pt0.y - y1) < _constants.EPSILON && Math.abs(pt1.x - x0) < _constants.EPSILON && Math.abs(pt1.y - y0) < _constants.EPSILON) {
|
|
1052
1142
|
if (line.relatedVertices.size == 2) {
|
|
1053
1143
|
var relPt0 = point(x0, y0);
|
|
1054
1144
|
var relPt1 = point(x1, y1);
|
|
@@ -1064,7 +1154,7 @@ export function getRelatedVertices(x0, y0, x1, y1, layer) {
|
|
|
1064
1154
|
});
|
|
1065
1155
|
return relVerts;
|
|
1066
1156
|
}
|
|
1067
|
-
|
|
1157
|
+
function getCalcRectFromLine(x0, y0, x1, y1, thick, layer) {
|
|
1068
1158
|
// get line from vertex coordinate
|
|
1069
1159
|
var relVerts = getRelatedVertices(x0, y0, x1, y1, layer);
|
|
1070
1160
|
var dx = x1 - x0;
|
|
@@ -1110,7 +1200,7 @@ export function getCalcRectFromLine(x0, y0, x1, y1, thick, layer) {
|
|
|
1110
1200
|
}
|
|
1111
1201
|
};
|
|
1112
1202
|
}
|
|
1113
|
-
|
|
1203
|
+
function getAllLineSnap(allLineRects, curItemRect) {
|
|
1114
1204
|
var allLineSnap = [];
|
|
1115
1205
|
var cur = curItemRect;
|
|
1116
1206
|
if (cur === undefined || cur === null) return;else allLineRects.forEach(function (rect) {
|
|
@@ -1134,7 +1224,7 @@ export function getAllLineSnap(allLineRects, curItemRect) {
|
|
|
1134
1224
|
});
|
|
1135
1225
|
return allLineSnap;
|
|
1136
1226
|
}
|
|
1137
|
-
|
|
1227
|
+
function validateSnaps(allSnaps, allRects) {
|
|
1138
1228
|
var validSnaps = [];
|
|
1139
1229
|
if (allSnaps !== undefined && allSnaps !== null && allSnaps.length > 0) allSnaps.forEach(function (snap) {
|
|
1140
1230
|
if (validSnap(snap, allRects)) {
|
|
@@ -1143,7 +1233,7 @@ export function validateSnaps(allSnaps, allRects) {
|
|
|
1143
1233
|
});
|
|
1144
1234
|
return validSnaps;
|
|
1145
1235
|
}
|
|
1146
|
-
|
|
1236
|
+
function validateLineSnaps(allSnaps, allItemSnap, allLineSnap, allItemRects, allLineRects, allRects) {
|
|
1147
1237
|
var validSnaps = [];
|
|
1148
1238
|
allSnaps.forEach(function (snap) {
|
|
1149
1239
|
if (validSnap(snap, allRects)) {
|
|
@@ -1159,13 +1249,13 @@ export function validateLineSnaps(allSnaps, allItemSnap, allLineSnap, allItemRec
|
|
|
1159
1249
|
});
|
|
1160
1250
|
return validSnaps;
|
|
1161
1251
|
}
|
|
1162
|
-
|
|
1252
|
+
function validSnap(snap, rects) {
|
|
1163
1253
|
var snaprect = getCalcRectFromItem(snap);
|
|
1164
1254
|
return rects.every(function (rect) {
|
|
1165
1255
|
return !intersectRect(rect.rect, snaprect.rect);
|
|
1166
1256
|
});
|
|
1167
1257
|
}
|
|
1168
|
-
|
|
1258
|
+
function itemInfo(x, y, rotRad, size) {
|
|
1169
1259
|
return {
|
|
1170
1260
|
pos: {
|
|
1171
1261
|
x: x,
|
|
@@ -1175,7 +1265,7 @@ export function itemInfo(x, y, rotRad, size) {
|
|
|
1175
1265
|
size: size
|
|
1176
1266
|
};
|
|
1177
1267
|
}
|
|
1178
|
-
|
|
1268
|
+
function intersectRect(rect1, rect2) {
|
|
1179
1269
|
var ret = false;
|
|
1180
1270
|
rect1 = shrinkRect(rect1);
|
|
1181
1271
|
rect2 = shrinkRect(rect2);
|
|
@@ -1188,7 +1278,7 @@ export function intersectRect(rect1, rect2) {
|
|
|
1188
1278
|
});
|
|
1189
1279
|
return ret;
|
|
1190
1280
|
}
|
|
1191
|
-
|
|
1281
|
+
function containPointInRect(point, rect) {
|
|
1192
1282
|
// true: contain, false: not contain
|
|
1193
1283
|
for (var i = 0; i < rect.length; i++) {
|
|
1194
1284
|
var ni = (i + 1) % rect.length;
|
|
@@ -1198,16 +1288,16 @@ export function containPointInRect(point, rect) {
|
|
|
1198
1288
|
}
|
|
1199
1289
|
return true;
|
|
1200
1290
|
}
|
|
1201
|
-
|
|
1291
|
+
function diff(v0, v1) {
|
|
1202
1292
|
return {
|
|
1203
1293
|
x: v0.x - v1.x,
|
|
1204
1294
|
y: v0.y - v1.y
|
|
1205
1295
|
};
|
|
1206
1296
|
}
|
|
1207
|
-
|
|
1297
|
+
function crossprod(v0, v1) {
|
|
1208
1298
|
return v0.x * v1.y - v0.y * v1.x;
|
|
1209
1299
|
}
|
|
1210
|
-
|
|
1300
|
+
function shrinkRect(rect) {
|
|
1211
1301
|
var v02x = rect[2].x - rect[0].x;
|
|
1212
1302
|
var v02y = rect[2].y - rect[0].y;
|
|
1213
1303
|
var d02 = Math.sqrt(v02x * v02x + v02y * v02y);
|
|
@@ -1220,7 +1310,7 @@ export function shrinkRect(rect) {
|
|
|
1220
1310
|
var o13y = v13y / d13 * 0.1;
|
|
1221
1311
|
return [point(rect[0].x + o02x, rect[0].y + o02y), point(rect[1].x + o13x, rect[1].y + o13y), point(rect[2].x - o02x, rect[2].y - o02y), point(rect[3].x - o13x, rect[3].y - o13y)];
|
|
1222
1312
|
}
|
|
1223
|
-
|
|
1313
|
+
function getInterSect(shape1, shape2) {
|
|
1224
1314
|
// return result of intersect of two shape
|
|
1225
1315
|
var count = 0;
|
|
1226
1316
|
for (var i = 0; i < shape1.length; i++) {
|
|
@@ -1250,7 +1340,7 @@ export function getInterSect(shape1, shape2) {
|
|
|
1250
1340
|
}
|
|
1251
1341
|
return false;
|
|
1252
1342
|
}
|
|
1253
|
-
|
|
1343
|
+
function getLineInterSect(s1x, s1y, e1x, e1y, s2x, s2y, e2x, e2y) {
|
|
1254
1344
|
var ax = s1x;
|
|
1255
1345
|
var ay = s1y;
|
|
1256
1346
|
var bx = e1x - s1x;
|
|
@@ -1295,7 +1385,7 @@ export function getLineInterSect(s1x, s1y, e1x, e1y, s2x, s2y, e2x, e2y) {
|
|
|
1295
1385
|
return ret;
|
|
1296
1386
|
}
|
|
1297
1387
|
}
|
|
1298
|
-
|
|
1388
|
+
function isPointInArea(allArea, pt) {
|
|
1299
1389
|
var x = pt.x;
|
|
1300
1390
|
var y = pt.y;
|
|
1301
1391
|
var result = false;
|
|
@@ -1315,7 +1405,7 @@ export function isPointInArea(allArea, pt) {
|
|
|
1315
1405
|
x: x1 - x,
|
|
1316
1406
|
y: y1 - y
|
|
1317
1407
|
};
|
|
1318
|
-
if (Math.abs(v0.x) < EPSILON && Math.abs(v0.y) < EPSILON)
|
|
1408
|
+
if (Math.abs(v0.x) < _constants.EPSILON && Math.abs(v0.y) < _constants.EPSILON)
|
|
1319
1409
|
// check if pt is area point
|
|
1320
1410
|
return true;
|
|
1321
1411
|
|
|
@@ -1328,18 +1418,18 @@ export function isPointInArea(allArea, pt) {
|
|
|
1328
1418
|
};
|
|
1329
1419
|
var xE = x0 + vPt.x * lineLen;
|
|
1330
1420
|
var yE = y0 + vPt.y * lineLen;
|
|
1331
|
-
if (v0Len <= lineLen && Math.abs(xE - x1) < EPSILON && Math.abs(yE - y1) < EPSILON) return true;
|
|
1421
|
+
if (v0Len <= lineLen && Math.abs(xE - x1) < _constants.EPSILON && Math.abs(yE - y1) < _constants.EPSILON) return true;
|
|
1332
1422
|
alpha = Math.atan2(v0.x * v1.y - v1.x * v0.y, v0.x * v1.x + v0.y * v1.y);
|
|
1333
1423
|
sum += alpha;
|
|
1334
1424
|
}
|
|
1335
|
-
if (Math.abs(Math.abs(sum) - Math.PI * 2) < EPSILON) return true;
|
|
1425
|
+
if (Math.abs(Math.abs(sum) - Math.PI * 2) < _constants.EPSILON) return true;
|
|
1336
1426
|
});
|
|
1337
1427
|
return result;
|
|
1338
1428
|
}
|
|
1339
|
-
|
|
1429
|
+
function calcSnap(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, allAreaLines) {
|
|
1340
1430
|
return calcSnap2(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, allAreaLines);
|
|
1341
1431
|
}
|
|
1342
|
-
|
|
1432
|
+
function calcCreateSnap(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, polygonPoint) {
|
|
1343
1433
|
// Validate required input and guard against missing `.cur`
|
|
1344
1434
|
if (!allItemRect || !allItemRect.cur) return;
|
|
1345
1435
|
var cur = allItemRect.cur; // safe alias
|
|
@@ -1397,7 +1487,7 @@ export function calcCreateSnap(allItemRect, allItemSnap, allLineRects, allLineSn
|
|
|
1397
1487
|
}
|
|
1398
1488
|
|
|
1399
1489
|
////////////
|
|
1400
|
-
|
|
1490
|
+
function calcSnap1(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y) {
|
|
1401
1491
|
var cx = allItemRect.cur.pos.x;
|
|
1402
1492
|
var cy = allItemRect.cur.pos.y;
|
|
1403
1493
|
var nx = x;
|
|
@@ -1441,7 +1531,7 @@ export function calcSnap1(allItemRect, allItemSnap, allLineRects, allLineSnap, a
|
|
|
1441
1531
|
}
|
|
1442
1532
|
|
|
1443
1533
|
////////////
|
|
1444
|
-
|
|
1534
|
+
function calcSnap2(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, allArea) {
|
|
1445
1535
|
var nx = x;
|
|
1446
1536
|
var ny = y;
|
|
1447
1537
|
var ndist = 20;
|
|
@@ -1585,7 +1675,7 @@ export function calcSnap2(allItemRect, allItemSnap, allLineRects, allLineSnap, a
|
|
|
1585
1675
|
return intersectRect(others.rect, curitem.rect);
|
|
1586
1676
|
});
|
|
1587
1677
|
intersects.forEach(function (rect) {
|
|
1588
|
-
if (isPointInArea(allArea, rect.itemInfo) || !allArea.length) if (rect.itemInfo.layoutpos.includes(BASE_CABINET_LAYOUTPOS)) {
|
|
1678
|
+
if (isPointInArea(allArea, rect.itemInfo) || !allArea.length) if (rect.itemInfo.layoutpos.includes(_constants.BASE_CABINET_LAYOUTPOS)) {
|
|
1589
1679
|
nx = rect.itemInfo.x;
|
|
1590
1680
|
ny = rect.itemInfo.y;
|
|
1591
1681
|
rotRad = rect.itemInfo.rotation * Math.PI / 180;
|
|
@@ -1612,7 +1702,7 @@ export function calcSnap2(allItemRect, allItemSnap, allLineRects, allLineSnap, a
|
|
|
1612
1702
|
//Check case.
|
|
1613
1703
|
//If item is 'blind base cabinet', it must be pulled from other 3".
|
|
1614
1704
|
if (allItemRect.cur && allItemRect.cur.itemInfo.sku_number.startsWith('BBC')) {
|
|
1615
|
-
var offset3inch = convert(3).from('in').to('cm');
|
|
1705
|
+
var offset3inch = (0, _convertUnitsLite.convert)(3).from('in').to('cm');
|
|
1616
1706
|
var tx = nx,
|
|
1617
1707
|
ty = ny;
|
|
1618
1708
|
if (allItemRect.cur && allItemRect.cur.itemInfo.sku_number.endsWith('-L')) {
|
|
@@ -1657,7 +1747,7 @@ export function calcSnap2(allItemRect, allItemSnap, allLineRects, allLineSnap, a
|
|
|
1657
1747
|
}
|
|
1658
1748
|
|
|
1659
1749
|
////////////
|
|
1660
|
-
|
|
1750
|
+
function calcSnap3(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y) {
|
|
1661
1751
|
// let layer = scene.layers.get(layerID);
|
|
1662
1752
|
// let cx = allItemRect.cur.pos.x;
|
|
1663
1753
|
// let cy = allItemRect.cur.pos.y;
|
|
@@ -1772,10 +1862,10 @@ export function calcSnap3(allItemRect, allItemSnap, allLineRects, allLineSnap, a
|
|
|
1772
1862
|
rotRad: rotRad
|
|
1773
1863
|
};
|
|
1774
1864
|
}
|
|
1775
|
-
|
|
1865
|
+
function getAllCurSnap(allLineRects, x, y, curItemRect) {
|
|
1776
1866
|
if (!curItemRect) return;
|
|
1777
1867
|
var allCurSnap = [];
|
|
1778
|
-
var thick = LINE_THICKNESS / 2;
|
|
1868
|
+
var thick = _constants.LINE_THICKNESS / 2;
|
|
1779
1869
|
allLineRects.forEach(function (linerect) {
|
|
1780
1870
|
//allLineRects:left, right, top, bottom line
|
|
1781
1871
|
var p0 = clone_point(linerect.rect[2]); //point 2(x, y) inside of line
|
|
@@ -1810,15 +1900,15 @@ export function getAllCurSnap(allLineRects, x, y, curItemRect) {
|
|
|
1810
1900
|
});
|
|
1811
1901
|
return allCurSnap;
|
|
1812
1902
|
}
|
|
1813
|
-
|
|
1903
|
+
function clone_point(pt) {
|
|
1814
1904
|
return point(pt.x, pt.y);
|
|
1815
1905
|
}
|
|
1816
|
-
|
|
1906
|
+
function dotprod(v0, v1) {
|
|
1817
1907
|
return v0.x * v1.x + v0.y * v1.y;
|
|
1818
1908
|
}
|
|
1819
1909
|
|
|
1820
1910
|
//////////
|
|
1821
|
-
|
|
1911
|
+
function validInterSect(rect, val) {
|
|
1822
1912
|
var curitem = getCalcRectFromItem(val);
|
|
1823
1913
|
var datas = [];
|
|
1824
1914
|
rect.forEach(function (line) {
|
|
@@ -1848,7 +1938,7 @@ var lineRect = function lineRect(layer) {
|
|
|
1848
1938
|
});
|
|
1849
1939
|
return rect;
|
|
1850
1940
|
};
|
|
1851
|
-
|
|
1941
|
+
function getAllHoleRect(scene, val) {
|
|
1852
1942
|
var layerID = scene.selectedLayer;
|
|
1853
1943
|
var layer = scene.layers.get(layerID);
|
|
1854
1944
|
var selectedItem = layer.getIn(['items', layer.selected.items.get(0)]);
|
|
@@ -1892,7 +1982,7 @@ export function getAllHoleRect(scene, val) {
|
|
|
1892
1982
|
y: vertice1.y
|
|
1893
1983
|
};
|
|
1894
1984
|
var rotation = Math.atan2(point1.y - point0.y, point1.x - point0.x);
|
|
1895
|
-
var rectInfo = getCalcRectFromLine(point0.x, point0.y, point1.x, point1.y, LINE_THICKNESS, layer);
|
|
1985
|
+
var rectInfo = getCalcRectFromLine(point0.x, point0.y, point1.x, point1.y, _constants.LINE_THICKNESS, layer);
|
|
1896
1986
|
var vN = point(rectInfo.rect[0].x - rectInfo.rect[3].x, rectInfo.rect[0].y - rectInfo.rect[3].y);
|
|
1897
1987
|
var lenN = Math.sqrt(vN.x * vN.x + vN.y * vN.y);
|
|
1898
1988
|
vN.x /= lenN;
|
|
@@ -1914,7 +2004,7 @@ export function getAllHoleRect(scene, val) {
|
|
|
1914
2004
|
};
|
|
1915
2005
|
var hole_rect = getCalcRectFromItem(tval);
|
|
1916
2006
|
if (intersectRect(itemRect.rect, hole_rect.rect)) {
|
|
1917
|
-
if (tdepth > itemRect.size.depth && itemRect.layoutpos !== WALL_CABINET_LAYOUTPOS) {
|
|
2007
|
+
if (tdepth > itemRect.size.depth && itemRect.layoutpos !== _constants.WALL_CABINET_LAYOUTPOS) {
|
|
1918
2008
|
var dist = itemRect.size.height / 2 + theight / 2;
|
|
1919
2009
|
var snap = [];
|
|
1920
2010
|
var p0 = {
|
|
@@ -1947,7 +2037,7 @@ export function getAllHoleRect(scene, val) {
|
|
|
1947
2037
|
snap: null
|
|
1948
2038
|
};
|
|
1949
2039
|
}
|
|
1950
|
-
|
|
2040
|
+
function getHoleItems(layer) {
|
|
1951
2041
|
var holeItems = [];
|
|
1952
2042
|
layer.holes.map(function (hole) {
|
|
1953
2043
|
var width = hole.properties.getIn(['width', 'length']);
|
|
@@ -1961,18 +2051,18 @@ export function getHoleItems(layer) {
|
|
|
1961
2051
|
});
|
|
1962
2052
|
return holeItems;
|
|
1963
2053
|
}
|
|
1964
|
-
|
|
2054
|
+
function needSnap(curItem, othItem) {
|
|
1965
2055
|
var blSnap = false;
|
|
1966
2056
|
if (curItem == undefined || curItem == null) return false;
|
|
1967
2057
|
var altitude = curItem.selectedItem.properties.get('altitude');
|
|
1968
|
-
var heightFromFloor = convert(altitude.get('_length')).from(altitude.get('_unit')).to('in');
|
|
2058
|
+
var heightFromFloor = (0, _convertUnitsLite.convert)(altitude.get('_length')).from(altitude.get('_unit')).to('in');
|
|
1969
2059
|
var height = curItem.cat.info.sizeinfo.height;
|
|
1970
2060
|
var currentItem = {
|
|
1971
2061
|
heightFromFloor: heightFromFloor,
|
|
1972
2062
|
height: height
|
|
1973
2063
|
};
|
|
1974
2064
|
altitude = othItem.item.properties.get('altitude');
|
|
1975
|
-
heightFromFloor = convert(altitude.get('_length')).from(altitude.get('_unit')).to('in');
|
|
2065
|
+
heightFromFloor = (0, _convertUnitsLite.convert)(altitude.get('_length')).from(altitude.get('_unit')).to('in');
|
|
1976
2066
|
height = othItem.cat && othItem.cat.info.sizeinfo.height;
|
|
1977
2067
|
var otherItem = {
|
|
1978
2068
|
heightFromFloor: heightFromFloor,
|
|
@@ -1990,7 +2080,7 @@ export function needSnap(curItem, othItem) {
|
|
|
1990
2080
|
}
|
|
1991
2081
|
return blSnap;
|
|
1992
2082
|
}
|
|
1993
|
-
|
|
2083
|
+
function isFrontWall(v0, v1) {
|
|
1994
2084
|
var x1 = v0.x,
|
|
1995
2085
|
y1 = v0.y;
|
|
1996
2086
|
var x2 = v1.x,
|
|
@@ -1998,7 +2088,7 @@ export function isFrontWall(v0, v1) {
|
|
|
1998
2088
|
var alpha = angleBetweenTwoPoints(x1, y1, x2, y2);
|
|
1999
2089
|
return almostEqual(y1, y2) && x1 < x2 || -Math.PI / 2 < alpha && alpha < Math.PI / 2;
|
|
2000
2090
|
}
|
|
2001
|
-
|
|
2091
|
+
function isBackWall(v0, v1) {
|
|
2002
2092
|
var x1 = v0.x,
|
|
2003
2093
|
y1 = v0.y;
|
|
2004
2094
|
var x2 = v1.x,
|
|
@@ -2006,7 +2096,7 @@ export function isBackWall(v0, v1) {
|
|
|
2006
2096
|
var alpha = angleBetweenTwoPoints(x1, y1, x2, y2);
|
|
2007
2097
|
return almostEqual(y1, y2) && x1 > x2 || -Math.PI / 2 > alpha || alpha > Math.PI / 2;
|
|
2008
2098
|
}
|
|
2009
|
-
|
|
2099
|
+
function isLeftWall(v0, v1) {
|
|
2010
2100
|
var x1 = v0.x,
|
|
2011
2101
|
y1 = v0.y;
|
|
2012
2102
|
var x2 = v1.x,
|
|
@@ -2014,7 +2104,7 @@ export function isLeftWall(v0, v1) {
|
|
|
2014
2104
|
var alpha = angleBetweenTwoPoints(x1, y1, x2, y2);
|
|
2015
2105
|
return almostEqual(x1, x2) && y1 < y2 || Math.PI > alpha && alpha > 0;
|
|
2016
2106
|
}
|
|
2017
|
-
|
|
2107
|
+
function isRightWall(v0, v1) {
|
|
2018
2108
|
var x1 = v0.x,
|
|
2019
2109
|
y1 = v0.y;
|
|
2020
2110
|
var x2 = v1.x,
|
|
@@ -2047,7 +2137,7 @@ export function isRightWall(v0, v1) {
|
|
|
2047
2137
|
//////// test - end /////////////
|
|
2048
2138
|
|
|
2049
2139
|
*/
|
|
2050
|
-
|
|
2140
|
+
function relationshipOfTwoOverlappedLines(srcLine, destLine) {
|
|
2051
2141
|
// let res1 = relationshipOfTwoOverlappedLines1(srcLine, destLine);
|
|
2052
2142
|
var res2 = relationshipOfTwoOverlappedLines2(srcLine, destLine);
|
|
2053
2143
|
// if (res1.result !== 0 || res2.result !== 0) {
|
|
@@ -2059,7 +2149,7 @@ export function relationshipOfTwoOverlappedLines(srcLine, destLine) {
|
|
|
2059
2149
|
// }
|
|
2060
2150
|
return res2;
|
|
2061
2151
|
}
|
|
2062
|
-
|
|
2152
|
+
function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
|
|
2063
2153
|
var p1 = {
|
|
2064
2154
|
x: srcLine.x1,
|
|
2065
2155
|
y: srcLine.y1
|
|
@@ -2087,10 +2177,10 @@ export function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
|
|
|
2087
2177
|
var denom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);
|
|
2088
2178
|
var numA = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3);
|
|
2089
2179
|
var numB = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3);
|
|
2090
|
-
if (fAbs(denom) <= EPSILON) {
|
|
2091
|
-
if (fAbs(numA) <= EPSILON && fAbs(numB) <= EPSILON) {
|
|
2180
|
+
if ((0, _math.fAbs)(denom) <= _constants.EPSILON) {
|
|
2181
|
+
if ((0, _math.fAbs)(numA) <= _constants.EPSILON && (0, _math.fAbs)(numB) <= _constants.EPSILON) {
|
|
2092
2182
|
var comparator = function comparator(pa, pb) {
|
|
2093
|
-
return fAbs(pa.x - pb.x) <= EPSILON ? pa.y - pb.y : pa.x - pb.x;
|
|
2183
|
+
return (0, _math.fAbs)(pa.x - pb.x) <= _constants.EPSILON ? pa.y - pb.y : pa.x - pb.x;
|
|
2094
2184
|
};
|
|
2095
2185
|
var line0 = [p1, p2].sort(comparator);
|
|
2096
2186
|
var line1 = [p3, p4].sort(comparator);
|
|
@@ -2099,7 +2189,7 @@ export function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
|
|
|
2099
2189
|
var _sort3 = [line0, line1].sort(function (lineA, lineB) {
|
|
2100
2190
|
return comparator(lineA[0], lineB[0]);
|
|
2101
2191
|
}),
|
|
2102
|
-
_sort4 =
|
|
2192
|
+
_sort4 = (0, _slicedToArray2["default"])(_sort3, 2),
|
|
2103
2193
|
lineSX = _sort4[0],
|
|
2104
2194
|
lineDX = _sort4[1];
|
|
2105
2195
|
var isReversedSrcLineIdx = false;
|
|
@@ -2107,17 +2197,17 @@ export function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
|
|
|
2107
2197
|
var compare0 = comparator(lineSX[0], lineDX[0]);
|
|
2108
2198
|
var compare1 = comparator(lineSX[1], lineDX[0]);
|
|
2109
2199
|
var compare2 = comparator(lineSX[1], lineDX[1]);
|
|
2110
|
-
if (MathUtils.fAbs(compare0) < EPSILON && MathUtils.fAbs(compare2) < EPSILON) {
|
|
2200
|
+
if (_export.MathUtils.fAbs(compare0) < _constants.EPSILON && _export.MathUtils.fAbs(compare2) < _constants.EPSILON) {
|
|
2111
2201
|
return {
|
|
2112
|
-
result: OVERLAP_SAME
|
|
2202
|
+
result: _constants.OVERLAP_SAME
|
|
2113
2203
|
};
|
|
2114
|
-
} else if (MathUtils.fAbs(compare0) < EPSILON && compare2 < 0) {
|
|
2204
|
+
} else if (_export.MathUtils.fAbs(compare0) < _constants.EPSILON && compare2 < 0) {
|
|
2115
2205
|
// lineDX includes lineSX
|
|
2116
2206
|
if (!isReversedSrcLineIdx) {
|
|
2117
2207
|
// dest === lineDX : dest includes src
|
|
2118
2208
|
// return OVERLAP_INCLUDED; // lineSX[1] - lineDX[1]
|
|
2119
2209
|
return {
|
|
2120
|
-
result: OVERLAP_INCLUDED
|
|
2210
|
+
result: _constants.OVERLAP_INCLUDED
|
|
2121
2211
|
};
|
|
2122
2212
|
}
|
|
2123
2213
|
// else {
|
|
@@ -2134,10 +2224,10 @@ export function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
|
|
|
2134
2224
|
// };
|
|
2135
2225
|
// }
|
|
2136
2226
|
}
|
|
2137
|
-
if (MathUtils.fAbs(compare1) < EPSILON) {
|
|
2227
|
+
if (_export.MathUtils.fAbs(compare1) < _constants.EPSILON) {
|
|
2138
2228
|
// return OVERLAP_LINK; // lineSX[1]
|
|
2139
2229
|
return {
|
|
2140
|
-
result: OVERLAP_LINK,
|
|
2230
|
+
result: _constants.OVERLAP_LINK,
|
|
2141
2231
|
linkedLine: {
|
|
2142
2232
|
x1: isReversedSrcLineDirection ? lineDX[1].x : lineSX[0].x,
|
|
2143
2233
|
y1: isReversedSrcLineDirection ? lineDX[1].y : lineSX[0].y,
|
|
@@ -2147,16 +2237,16 @@ export function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
|
|
|
2147
2237
|
};
|
|
2148
2238
|
} else if (compare1 < 0) {
|
|
2149
2239
|
return {
|
|
2150
|
-
result: OVERLAP_NONE
|
|
2240
|
+
result: _constants.OVERLAP_NONE
|
|
2151
2241
|
};
|
|
2152
2242
|
} else {
|
|
2153
|
-
if (MathUtils.fAbs(compare2) < EPSILON || compare2 > 0) {
|
|
2243
|
+
if (_export.MathUtils.fAbs(compare2) < _constants.EPSILON || compare2 > 0) {
|
|
2154
2244
|
// lineSX includes lineDX
|
|
2155
2245
|
if (isReversedSrcLineIdx) {
|
|
2156
2246
|
// dest === lineSX : dest includes src
|
|
2157
2247
|
// return OVERLAP_INCLUDED; // lineDX[0] - lineDX[1]
|
|
2158
2248
|
return {
|
|
2159
|
-
result: OVERLAP_INCLUDED
|
|
2249
|
+
result: _constants.OVERLAP_INCLUDED
|
|
2160
2250
|
};
|
|
2161
2251
|
} else {
|
|
2162
2252
|
// dest === lineDX : src includes dest
|
|
@@ -2175,7 +2265,7 @@ export function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
|
|
|
2175
2265
|
y2: isReversedSrcLineDirection ? lineDX[1].y : lineSX[1].y
|
|
2176
2266
|
});
|
|
2177
2267
|
return {
|
|
2178
|
-
result: OVERLAP_SOME,
|
|
2268
|
+
result: _constants.OVERLAP_SOME,
|
|
2179
2269
|
trimmedSegs: trimmedSegs
|
|
2180
2270
|
};
|
|
2181
2271
|
}
|
|
@@ -2196,7 +2286,7 @@ export function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
|
|
|
2196
2286
|
y2: isReversedSrcLineDirection ? lineSX[1].y : lineDX[1].y
|
|
2197
2287
|
});
|
|
2198
2288
|
return {
|
|
2199
|
-
result: OVERLAP_SOME,
|
|
2289
|
+
result: _constants.OVERLAP_SOME,
|
|
2200
2290
|
trimmedSegs: _trimmedSegs
|
|
2201
2291
|
};
|
|
2202
2292
|
}
|
|
@@ -2204,46 +2294,46 @@ export function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
|
|
|
2204
2294
|
}
|
|
2205
2295
|
}
|
|
2206
2296
|
return {
|
|
2207
|
-
result: OVERLAP_NONE
|
|
2297
|
+
result: _constants.OVERLAP_NONE
|
|
2208
2298
|
};
|
|
2209
2299
|
}
|
|
2210
|
-
|
|
2300
|
+
function relationshipOfTwoOverlappedLines1(srcLine, destLine) {
|
|
2211
2301
|
var INFINITY = 1000000;
|
|
2212
2302
|
var ZERO_DELTA = 0.01;
|
|
2213
2303
|
// geometric equation of srcLine
|
|
2214
2304
|
var dx1 = srcLine.x2 - srcLine.x1;
|
|
2215
|
-
dx1 = MathUtils.fAbs(dx1) < ZERO_DELTA ? 0 : dx1;
|
|
2305
|
+
dx1 = _export.MathUtils.fAbs(dx1) < ZERO_DELTA ? 0 : dx1;
|
|
2216
2306
|
var dy1 = srcLine.y2 - srcLine.y1;
|
|
2217
|
-
dy1 = MathUtils.fAbs(dy1) < ZERO_DELTA ? 0 : dy1;
|
|
2307
|
+
dy1 = _export.MathUtils.fAbs(dy1) < ZERO_DELTA ? 0 : dy1;
|
|
2218
2308
|
var a1 = dx1 === 0 ? INFINITY : dy1 / dx1;
|
|
2219
2309
|
var b1 = a1 === INFINITY ? srcLine.x1 : srcLine.y1 - a1 * srcLine.x1;
|
|
2220
2310
|
// geometric equation of destLine
|
|
2221
2311
|
var dx2 = destLine.x2 - destLine.x1;
|
|
2222
|
-
dx2 = MathUtils.fAbs(dx2) < ZERO_DELTA ? 0 : dx2;
|
|
2312
|
+
dx2 = _export.MathUtils.fAbs(dx2) < ZERO_DELTA ? 0 : dx2;
|
|
2223
2313
|
var dy2 = destLine.y2 - destLine.y1;
|
|
2224
|
-
dy2 = MathUtils.fAbs(dy2) < ZERO_DELTA ? 0 : dy2;
|
|
2314
|
+
dy2 = _export.MathUtils.fAbs(dy2) < ZERO_DELTA ? 0 : dy2;
|
|
2225
2315
|
var a2 = dx2 === 0 ? INFINITY : dy2 / dx2;
|
|
2226
2316
|
var b2 = a2 === INFINITY ? destLine.x1 : destLine.y1 - a2 * destLine.x1;
|
|
2227
|
-
if (MathUtils.fAbs(MathUtils.fAbs(a1) - MathUtils.fAbs(a2)) > ZERO_DELTA)
|
|
2317
|
+
if (_export.MathUtils.fAbs(_export.MathUtils.fAbs(a1) - _export.MathUtils.fAbs(a2)) > ZERO_DELTA)
|
|
2228
2318
|
// two lines are not parallel
|
|
2229
2319
|
return {
|
|
2230
|
-
result: OVERLAP_NONE
|
|
2320
|
+
result: _constants.OVERLAP_NONE
|
|
2231
2321
|
};
|
|
2232
|
-
if (MathUtils.fAbs(MathUtils.fAbs(b1) - MathUtils.fAbs(b2)) > ZERO_DELTA)
|
|
2322
|
+
if (_export.MathUtils.fAbs(_export.MathUtils.fAbs(b1) - _export.MathUtils.fAbs(b2)) > ZERO_DELTA)
|
|
2233
2323
|
// two lines are parallel but not overlap
|
|
2234
2324
|
return {
|
|
2235
|
-
result: OVERLAP_NONE
|
|
2325
|
+
result: _constants.OVERLAP_NONE
|
|
2236
2326
|
};
|
|
2237
2327
|
|
|
2238
2328
|
// parametric equation of destLine
|
|
2239
|
-
var sk1 = dx1 === 0 ? INFINITY : MathUtils.toFixedFloat((destLine.x1 - srcLine.x1) / dx1, 3);
|
|
2240
|
-
var sk2 = dy1 === 0 ? INFINITY : MathUtils.toFixedFloat((destLine.y1 - srcLine.y1) / dy1, 3);
|
|
2241
|
-
var ek1 = dx1 === 0 ? INFINITY : MathUtils.toFixedFloat((destLine.x2 - srcLine.x1) / dx1, 3);
|
|
2242
|
-
var ek2 = dy1 === 0 ? INFINITY : MathUtils.toFixedFloat((destLine.y2 - srcLine.y1) / dy1, 3);
|
|
2329
|
+
var sk1 = dx1 === 0 ? INFINITY : _export.MathUtils.toFixedFloat((destLine.x1 - srcLine.x1) / dx1, 3);
|
|
2330
|
+
var sk2 = dy1 === 0 ? INFINITY : _export.MathUtils.toFixedFloat((destLine.y1 - srcLine.y1) / dy1, 3);
|
|
2331
|
+
var ek1 = dx1 === 0 ? INFINITY : _export.MathUtils.toFixedFloat((destLine.x2 - srcLine.x1) / dx1, 3);
|
|
2332
|
+
var ek2 = dy1 === 0 ? INFINITY : _export.MathUtils.toFixedFloat((destLine.y2 - srcLine.y1) / dy1, 3);
|
|
2243
2333
|
if (sk1 !== INFINITY && sk2 !== INFINITY && ek1 !== INFINITY && ek2 !== INFINITY && (sk1 !== sk2 || ek1 !== ek2))
|
|
2244
2334
|
// destLine does not overlap with srcLine
|
|
2245
2335
|
return {
|
|
2246
|
-
result: OVERLAP_NONE
|
|
2336
|
+
result: _constants.OVERLAP_NONE
|
|
2247
2337
|
};
|
|
2248
2338
|
|
|
2249
2339
|
// parameter of destLine on the start and end points
|
|
@@ -2257,17 +2347,17 @@ export function relationshipOfTwoOverlappedLines1(srcLine, destLine) {
|
|
|
2257
2347
|
if (sk < 0 && ek < 0 || sk > 1 && ek > 1)
|
|
2258
2348
|
// not overlap
|
|
2259
2349
|
return {
|
|
2260
|
-
result: OVERLAP_NONE
|
|
2350
|
+
result: _constants.OVERLAP_NONE
|
|
2261
2351
|
};
|
|
2262
2352
|
if (sk === 0 && ek === 1 || sk === 1 && ek === 0)
|
|
2263
2353
|
// same lines
|
|
2264
2354
|
return {
|
|
2265
|
-
result: OVERLAP_SAME
|
|
2355
|
+
result: _constants.OVERLAP_SAME
|
|
2266
2356
|
};
|
|
2267
2357
|
if (sk <= 0 && ek >= 1 || sk >= 1 && ek <= 0)
|
|
2268
2358
|
// destLine includes srcLine
|
|
2269
2359
|
return {
|
|
2270
|
-
result: OVERLAP_INCLUDED
|
|
2360
|
+
result: _constants.OVERLAP_INCLUDED
|
|
2271
2361
|
};
|
|
2272
2362
|
if (sk === 0 && ek < 0 || sk === 1 && ek > 1 || ek === 0 && sk < 0 || ek === 1 && sk > 1) {
|
|
2273
2363
|
// linked with one common point
|
|
@@ -2310,14 +2400,14 @@ export function relationshipOfTwoOverlappedLines1(srcLine, destLine) {
|
|
|
2310
2400
|
};
|
|
2311
2401
|
}
|
|
2312
2402
|
return {
|
|
2313
|
-
result: OVERLAP_LINK,
|
|
2403
|
+
result: _constants.OVERLAP_LINK,
|
|
2314
2404
|
linkedLine: linkedLine
|
|
2315
2405
|
};
|
|
2316
2406
|
}
|
|
2317
2407
|
var trimmedSegment1 = null;
|
|
2318
2408
|
var trimmedSegment2 = null;
|
|
2319
2409
|
var ret = {
|
|
2320
|
-
result: OVERLAP_SOME,
|
|
2410
|
+
result: _constants.OVERLAP_SOME,
|
|
2321
2411
|
trimmedSegs: []
|
|
2322
2412
|
};
|
|
2323
2413
|
if (0 <= sk && sk <= 1 && 0 <= ek && ek <= 1) {
|
|
@@ -2403,7 +2493,7 @@ export function relationshipOfTwoOverlappedLines1(srcLine, destLine) {
|
|
|
2403
2493
|
* @param {Array} points //points of polygon
|
|
2404
2494
|
* @returns {Array} [centroid.x, centroid.y]
|
|
2405
2495
|
*/
|
|
2406
|
-
|
|
2496
|
+
function getCentroidOfPolygon(points) {
|
|
2407
2497
|
var center = points.reduce(function (x, y) {
|
|
2408
2498
|
return [x[0] + y[0] / points.length, x[1] + y[1] / points.length];
|
|
2409
2499
|
}, [0, 0]);
|