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