kitchen-simulator 1.1.1-test.6 → 1.1.1-test.61
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 +10 -2
- package/es/AppContext.js +10 -3
- package/es/KitchenConfigurator.js +95 -106
- package/es/KitchenConfiguratorApp.js +145 -154
- package/es/actions/area-actions.js +12 -5
- package/es/actions/export.js +29 -12
- package/es/actions/groups-actions.js +45 -27
- package/es/actions/holes-actions.js +55 -34
- package/es/actions/items-actions.js +145 -94
- package/es/actions/lines-actions.js +36 -21
- package/es/actions/project-actions.js +145 -94
- package/es/actions/scene-actions.js +21 -11
- package/es/actions/vertices-actions.js +15 -7
- package/es/actions/viewer2d-actions.js +36 -21
- package/es/actions/viewer3d-actions.js +18 -9
- package/es/catalog/areas/area/planner-element.js +18 -8
- package/es/catalog/catalog.js +21 -24
- package/es/catalog/factories/area-factory-3d.js +31 -22
- package/es/catalog/factories/area-factory.js +20 -14
- package/es/catalog/factories/export.js +24 -6
- package/es/catalog/factories/wall-factory-3d.js +41 -31
- package/es/catalog/factories/wall-factory.js +31 -21
- package/es/catalog/holes/door-closet/planner-element.js +24 -15
- package/es/catalog/holes/door-double/planner-element.js +24 -15
- package/es/catalog/holes/door-exterior/planner-element.js +25 -16
- package/es/catalog/holes/door-interior/planner-element.js +25 -16
- package/es/catalog/holes/door-panic/planner-element.js +16 -7
- package/es/catalog/holes/door-panic-double/planner-element.js +24 -15
- package/es/catalog/holes/door-sliding/planner-element.js +25 -16
- package/es/catalog/holes/doorway-framed/planner-element.js +20 -11
- package/es/catalog/holes/doorway-frameless/planner-element.js +16 -7
- package/es/catalog/holes/export.js +97 -13
- package/es/catalog/holes/window-clear/planner-element.js +19 -10
- package/es/catalog/holes/window-cross/planner-element.js +19 -10
- package/es/catalog/holes/window-double-hung/planner-element.js +19 -10
- package/es/catalog/holes/window-vertical/planner-element.js +19 -10
- package/es/catalog/lines/wall/planner-element.js +21 -11
- package/es/catalog/molding/molding-dcm/planner-element.js +14 -5
- package/es/catalog/molding/molding-fbm/planner-element.js +14 -5
- package/es/catalog/molding/molding-lrm/planner-element.js +14 -5
- package/es/catalog/properties/export.js +80 -20
- package/es/catalog/properties/property-checkbox.js +84 -35
- package/es/catalog/properties/property-color.js +23 -16
- package/es/catalog/properties/property-enum.js +72 -28
- package/es/catalog/properties/property-hidden.js +16 -9
- package/es/catalog/properties/property-lenght-measure.js +45 -39
- package/es/catalog/properties/property-length-measure.js +84 -34
- package/es/catalog/properties/property-length-measure_hole.js +45 -39
- package/es/catalog/properties/property-number.js +24 -17
- package/es/catalog/properties/property-read-only.js +23 -16
- package/es/catalog/properties/property-string.js +23 -16
- package/es/catalog/properties/property-toggle.js +23 -16
- package/es/catalog/properties/shared-property-style.js +7 -1
- package/es/catalog/utils/FuseUtils.js +15 -11
- package/es/catalog/utils/exporter.js +15 -11
- package/es/catalog/utils/geom-utils.js +29 -13
- package/es/catalog/utils/item-loader.js +97 -91
- package/es/catalog/utils/load-obj.js +28 -20
- package/es/catalog/utils/mtl-loader.js +9 -3
- package/es/catalog/utils/obj-loader.js +9 -3
- package/es/class/FuseUtils.js +15 -11
- package/es/class/area.js +28 -26
- package/es/class/export.js +95 -23
- package/es/class/group.js +59 -62
- package/es/class/guide.js +21 -19
- package/es/class/hole.js +89 -88
- package/es/class/item.js +150 -155
- package/es/class/layer.js +65 -63
- package/es/class/line.js +143 -144
- package/es/class/project.js +98 -94
- package/es/class/vertex.js +35 -33
- package/es/components/content.js +29 -19
- package/es/components/disclaimer/disclaimer.js +80 -92
- package/es/components/export.js +32 -8
- package/es/components/style/button.js +31 -30
- package/es/components/style/cancel-button.js +14 -8
- package/es/components/style/content-container.js +16 -12
- package/es/components/style/content-title.js +20 -15
- package/es/components/style/delete-button.js +17 -9
- package/es/components/style/export.js +120 -30
- package/es/components/style/form-block.js +15 -12
- package/es/components/style/form-color-input.js +14 -8
- package/es/components/style/form-label.js +15 -12
- package/es/components/style/form-number-input.js +73 -47
- package/es/components/style/form-number-input_2.js +44 -42
- package/es/components/style/form-select.js +60 -14
- package/es/components/style/form-slider.js +38 -16
- package/es/components/style/form-submit-button.js +17 -9
- package/es/components/style/form-text-input.js +57 -37
- package/es/components/viewer2d/area.js +24 -17
- package/es/components/viewer2d/export.js +120 -30
- package/es/components/viewer2d/grids/grid-horizontal-streak.js +17 -11
- package/es/components/viewer2d/grids/grid-streak.js +17 -11
- package/es/components/viewer2d/grids/grid-vertical-streak.js +17 -11
- package/es/components/viewer2d/grids/grids.js +19 -15
- package/es/components/viewer2d/group.js +24 -15
- package/es/components/viewer2d/item.js +70 -68
- package/es/components/viewer2d/layer.js +30 -23
- package/es/components/viewer2d/line.js +111 -104
- package/es/components/viewer2d/ruler.js +29 -23
- package/es/components/viewer2d/rulerDist.js +28 -21
- package/es/components/viewer2d/rulerX.js +47 -45
- package/es/components/viewer2d/rulerY.js +45 -43
- package/es/components/viewer2d/scene.js +42 -46
- package/es/components/viewer2d/snap.js +22 -13
- package/es/components/viewer2d/state.js +27 -23
- package/es/components/viewer2d/utils.js +65 -21
- package/es/components/viewer2d/vertex.js +17 -8
- package/es/components/viewer2d/viewer2d.js +171 -166
- package/es/components/viewer3d/camera-controls-module/camera-controls.module.js +23 -24
- package/es/components/viewer3d/dcm.js +7 -1
- package/es/components/viewer3d/fbm.js +7 -1
- package/es/components/viewer3d/front3D.js +21 -17
- package/es/components/viewer3d/grid-creator.js +17 -8
- package/es/components/viewer3d/grids/grid-horizontal-streak.js +14 -6
- package/es/components/viewer3d/grids/grid-streak.js +13 -5
- package/es/components/viewer3d/grids/grid-vertical-streak.js +14 -6
- package/es/components/viewer3d/libs/first-person-controls.js +9 -2
- package/es/components/viewer3d/libs/helvetiker_regular.typeface.js +7 -1
- package/es/components/viewer3d/libs/mtl-loader.js +8 -2
- package/es/components/viewer3d/libs/obj-loader.js +8 -2
- package/es/components/viewer3d/libs/orbit-controls.js +12 -5
- package/es/components/viewer3d/libs/pointer-lock-controls.js +11 -4
- package/es/components/viewer3d/lrm.js +7 -1
- package/es/components/viewer3d/model.js +7 -1
- package/es/components/viewer3d/pointer-lock-navigation.js +10 -3
- package/es/components/viewer3d/ruler-utils/itemRect.js +25 -18
- package/es/components/viewer3d/ruler-utils/layer3D.js +66 -59
- package/es/components/viewer3d/ruler-utils/ruler3D.js +46 -42
- package/es/components/viewer3d/ruler-utils/scene3D.js +18 -11
- package/es/components/viewer3d/ruler-utils/state3D.js +11 -4
- package/es/components/viewer3d/scene-creator.js +227 -198
- package/es/components/viewer3d/three-memory-cleaner.js +12 -3
- package/es/components/viewer3d/viewer3d-first-person.js +46 -46
- package/es/components/viewer3d/viewer3d.js +208 -209
- package/es/constants.js +358 -349
- package/es/index.js +28 -15
- package/es/models.js +185 -183
- package/es/plugins/SVGLoader.js +53 -48
- package/es/plugins/autosave.js +9 -3
- package/es/plugins/console-debugger.js +12 -8
- package/es/plugins/export.js +32 -8
- package/es/plugins/keyboard.js +35 -29
- package/es/reducers/areas-reducer.js +13 -7
- package/es/reducers/export.js +96 -24
- package/es/reducers/groups-reducer.js +37 -31
- package/es/reducers/holes-reducer.js +49 -43
- package/es/reducers/items-reducer.js +112 -109
- package/es/reducers/lines-reducer.js +34 -28
- package/es/reducers/project-reducer.js +111 -105
- package/es/reducers/reducer.js +23 -16
- package/es/reducers/scene-reducer.js +21 -15
- package/es/reducers/user-reducer.js +11 -6
- package/es/reducers/vertices-reducer.js +17 -11
- package/es/reducers/viewer2d-reducer.js +24 -18
- package/es/reducers/viewer3d-reducer.js +22 -16
- package/es/shared-style.js +16 -10
- package/es/styles/export.js +11 -3
- package/es/translator/en.js +7 -1
- package/es/translator/it.js +7 -1
- package/es/translator/ru.js +7 -1
- package/es/translator/translator.js +19 -17
- package/es/utils/browser.js +9 -2
- package/es/utils/convert-units-lite.js +35 -0
- package/es/utils/email-validator.js +7 -1
- package/es/utils/export.js +46 -15
- package/es/utils/geometry.js +279 -191
- package/es/utils/get-edges-of-subgraphs.js +9 -1
- package/es/utils/graph-cycles.js +11 -9
- package/es/utils/graph-inner-cycles.js +18 -10
- package/es/utils/graph.js +17 -12
- package/es/utils/helper.js +63 -109
- package/es/utils/history.js +15 -8
- package/es/utils/id-broker.js +15 -12
- package/es/utils/logger.js +7 -1
- package/es/utils/math.js +12 -5
- package/es/utils/molding.js +177 -158
- package/es/utils/name-generator.js +13 -11
- package/es/utils/objects-utils.js +19 -7
- package/es/utils/phone-validator.js +7 -1
- package/es/utils/process-black-list.js +10 -6
- package/es/utils/react-if.js +12 -6
- package/es/utils/snap-scene.js +34 -32
- package/es/utils/snap.js +59 -51
- package/es/utils/summarizeCart.js +7 -1
- package/es/utils/threeCSG.es6.js +22 -17
- package/es/version.js +7 -1
- package/lib/@history.js +1 -1
- package/lib/AppContext.js +1 -1
- package/lib/KitchenConfigurator.js +68 -87
- package/lib/KitchenConfiguratorApp.js +94 -110
- package/lib/actions/export.js +1 -1
- package/lib/catalog/areas/area/planner-element.js +12 -8
- package/lib/catalog/catalog.js +7 -15
- package/lib/catalog/factories/area-factory-3d.js +1 -1
- package/lib/catalog/factories/area-factory.js +4 -6
- package/lib/catalog/factories/export.js +1 -1
- package/lib/catalog/factories/wall-factory-3d.js +4 -4
- package/lib/catalog/factories/wall-factory.js +2 -2
- package/lib/catalog/holes/door-closet/planner-element.js +2 -2
- package/lib/catalog/holes/door-double/planner-element.js +2 -2
- package/lib/catalog/holes/door-exterior/planner-element.js +2 -2
- package/lib/catalog/holes/door-interior/planner-element.js +2 -2
- package/lib/catalog/holes/door-panic/planner-element.js +2 -2
- package/lib/catalog/holes/door-panic-double/planner-element.js +2 -2
- package/lib/catalog/holes/door-sliding/planner-element.js +2 -2
- package/lib/catalog/holes/doorway-framed/planner-element.js +2 -2
- package/lib/catalog/holes/doorway-frameless/planner-element.js +2 -2
- package/lib/catalog/holes/export.js +14 -14
- package/lib/catalog/holes/window-clear/planner-element.js +2 -2
- package/lib/catalog/holes/window-cross/planner-element.js +2 -2
- package/lib/catalog/holes/window-double-hung/planner-element.js +2 -2
- package/lib/catalog/holes/window-vertical/planner-element.js +2 -2
- package/lib/catalog/lines/wall/planner-element.js +15 -11
- package/lib/catalog/molding/molding-dcm/planner-element.js +2 -2
- package/lib/catalog/molding/molding-fbm/planner-element.js +2 -2
- package/lib/catalog/molding/molding-lrm/planner-element.js +2 -2
- package/lib/catalog/properties/export.js +1 -1
- package/lib/catalog/properties/property-checkbox.js +66 -24
- package/lib/catalog/properties/property-color.js +1 -1
- package/lib/catalog/properties/property-enum.js +52 -15
- package/lib/catalog/properties/property-hidden.js +1 -1
- package/lib/catalog/properties/property-lenght-measure.js +8 -9
- package/lib/catalog/properties/property-length-measure.js +59 -16
- package/lib/catalog/properties/property-length-measure_hole.js +8 -9
- package/lib/catalog/properties/property-number.js +1 -1
- package/lib/catalog/properties/property-read-only.js +1 -1
- package/lib/catalog/properties/property-string.js +1 -1
- package/lib/catalog/properties/property-toggle.js +1 -1
- package/lib/catalog/utils/FuseUtils.js +8 -10
- package/lib/catalog/utils/exporter.js +8 -11
- package/lib/catalog/utils/geom-utils.js +1 -1
- package/lib/catalog/utils/item-loader.js +29 -35
- package/lib/catalog/utils/mtl-loader.js +7 -3
- package/lib/catalog/utils/obj-loader.js +7 -3
- package/lib/class/FuseUtils.js +8 -10
- package/lib/class/area.js +7 -10
- package/lib/class/export.js +1 -1
- package/lib/class/group.js +11 -19
- package/lib/class/guide.js +9 -12
- package/lib/class/hole.js +5 -8
- package/lib/class/item.js +23 -34
- package/lib/class/layer.js +5 -8
- package/lib/class/line.js +12 -19
- package/lib/class/project.js +8 -10
- package/lib/class/vertex.js +7 -10
- package/lib/components/content.js +3 -2
- package/lib/components/disclaimer/disclaimer.js +67 -87
- package/lib/components/export.js +1 -1
- package/lib/components/style/button.js +15 -21
- package/lib/components/style/cancel-button.js +5 -6
- package/lib/components/style/content-container.js +3 -6
- package/lib/components/style/content-title.js +8 -11
- package/lib/components/style/delete-button.js +6 -7
- package/lib/components/style/export.js +1 -1
- package/lib/components/style/form-block.js +7 -11
- package/lib/components/style/form-color-input.js +5 -6
- package/lib/components/style/form-label.js +7 -11
- package/lib/components/style/form-number-input.js +41 -22
- package/lib/components/style/form-number-input_2.js +13 -18
- package/lib/components/style/form-select.js +51 -14
- package/lib/components/style/form-slider.js +26 -11
- package/lib/components/style/form-submit-button.js +6 -7
- package/lib/components/style/form-text-input.js +44 -31
- package/lib/components/viewer2d/area.js +6 -6
- package/lib/components/viewer2d/export.js +1 -1
- package/lib/components/viewer2d/grids/grid-horizontal-streak.js +1 -2
- package/lib/components/viewer2d/grids/grid-streak.js +1 -2
- package/lib/components/viewer2d/grids/grid-vertical-streak.js +1 -2
- package/lib/components/viewer2d/grids/grids.js +4 -9
- package/lib/components/viewer2d/group.js +2 -2
- package/lib/components/viewer2d/item.js +12 -18
- package/lib/components/viewer2d/layer.js +1 -1
- package/lib/components/viewer2d/line.js +4 -7
- package/lib/components/viewer2d/ruler.js +7 -8
- package/lib/components/viewer2d/rulerDist.js +5 -5
- package/lib/components/viewer2d/rulerX.js +13 -18
- package/lib/components/viewer2d/rulerY.js +13 -18
- package/lib/components/viewer2d/scene.js +22 -33
- package/lib/components/viewer2d/snap.js +2 -2
- package/lib/components/viewer2d/state.js +5 -10
- package/lib/components/viewer2d/utils.js +35 -2
- package/lib/components/viewer2d/vertex.js +2 -2
- package/lib/components/viewer2d/viewer2d.js +38 -40
- package/lib/components/viewer3d/camera-controls-module/camera-controls.module.js +14 -20
- package/lib/components/viewer3d/front3D.js +4 -9
- package/lib/components/viewer3d/grid-creator.js +2 -2
- package/lib/components/viewer3d/grids/grid-horizontal-streak.js +1 -1
- package/lib/components/viewer3d/grids/grid-streak.js +1 -1
- package/lib/components/viewer3d/grids/grid-vertical-streak.js +1 -1
- package/lib/components/viewer3d/libs/mtl-loader.js +6 -2
- package/lib/components/viewer3d/libs/obj-loader.js +6 -2
- package/lib/components/viewer3d/libs/orbit-controls.js +10 -5
- package/lib/components/viewer3d/libs/pointer-lock-controls.js +9 -4
- package/lib/components/viewer3d/pointer-lock-navigation.js +1 -1
- package/lib/components/viewer3d/ruler-utils/itemRect.js +8 -8
- package/lib/components/viewer3d/ruler-utils/layer3D.js +33 -33
- package/lib/components/viewer3d/ruler-utils/ruler3D.js +3 -6
- package/lib/components/viewer3d/ruler-utils/scene3D.js +4 -5
- package/lib/components/viewer3d/ruler-utils/state3D.js +1 -1
- package/lib/components/viewer3d/scene-creator.js +40 -45
- package/lib/components/viewer3d/three-memory-cleaner.js +1 -1
- package/lib/components/viewer3d/viewer3d-first-person.js +11 -16
- package/lib/components/viewer3d/viewer3d.js +32 -37
- package/lib/index.js +22 -88
- package/lib/models.js +58 -63
- package/lib/plugins/console-debugger.js +3 -6
- package/lib/plugins/export.js +1 -1
- package/lib/reducers/export.js +1 -1
- package/lib/reducers/user-reducer.js +0 -1
- package/lib/reducers/viewer2d-reducer.js +3 -4
- package/lib/reducers/viewer3d-reducer.js +3 -4
- package/lib/styles/export.js +1 -1
- package/lib/translator/translator.js +5 -9
- package/lib/utils/convert-units-lite.js +35 -0
- package/lib/utils/export.js +2 -2
- package/lib/utils/geometry.js +20 -28
- package/lib/utils/get-edges-of-subgraphs.js +7 -1
- package/lib/utils/graph-cycles.js +9 -9
- package/lib/utils/graph-inner-cycles.js +1 -1
- package/lib/utils/graph.js +15 -12
- package/lib/utils/helper.js +14 -83
- package/lib/utils/history.js +1 -1
- package/lib/utils/id-broker.js +7 -10
- package/lib/utils/molding.js +66 -71
- package/lib/utils/name-generator.js +5 -8
- package/lib/utils/objects-utils.js +5 -3
- package/lib/utils/process-black-list.js +3 -5
- package/lib/utils/react-if.js +1 -1
- package/lib/utils/snap-scene.js +3 -7
- package/lib/utils/snap.js +22 -26
- package/lib/utils/threeCSG.es6.js +14 -14
- package/package.json +24 -54
- package/es/analytics/ga4.js +0 -191
- package/es/analytics/posthog.js +0 -60
- package/lib/analytics/ga4.js +0 -197
- package/lib/analytics/posthog.js +0 -68
package/es/utils/geometry.js
CHANGED
|
@@ -1,90 +1,178 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.ContainsPoint = ContainsPoint;
|
|
9
|
+
exports._twoLineSegmentsIntersection = _twoLineSegmentsIntersection;
|
|
10
|
+
exports.absAngleBetweenTwoPoints = absAngleBetweenTwoPoints;
|
|
11
|
+
exports.almostEqual = void 0;
|
|
12
|
+
exports.angleBetweenTwoLines = angleBetweenTwoLines;
|
|
13
|
+
exports.angleBetweenTwoPoints = angleBetweenTwoPoints;
|
|
14
|
+
exports.angleBetweenTwoPointsAndOrigin = angleBetweenTwoPointsAndOrigin;
|
|
15
|
+
exports.buildRectFromLines = buildRectFromLines;
|
|
16
|
+
exports.calcCreateSnap = calcCreateSnap;
|
|
17
|
+
exports.calcSnap = calcSnap;
|
|
18
|
+
exports.calcSnap1 = calcSnap1;
|
|
19
|
+
exports.calcSnap2 = calcSnap2;
|
|
20
|
+
exports.calcSnap3 = calcSnap3;
|
|
21
|
+
exports.clone_point = clone_point;
|
|
22
|
+
exports.closestPointFromLine = closestPointFromLine;
|
|
23
|
+
exports.closestPointFromLineSegment = closestPointFromLineSegment;
|
|
24
|
+
exports.compareVertices = compareVertices;
|
|
25
|
+
exports.containLine = containLine;
|
|
26
|
+
exports.containPointInRect = containPointInRect;
|
|
27
|
+
exports.cosWithThreshold = cosWithThreshold;
|
|
28
|
+
exports.crossprod = crossprod;
|
|
29
|
+
exports.diff = diff;
|
|
30
|
+
exports.distancePointFromLine = distancePointFromLine;
|
|
31
|
+
exports.distancePointFromLineSegment = distancePointFromLineSegment;
|
|
32
|
+
exports.dotprod = dotprod;
|
|
33
|
+
exports.downcrossLine = downcrossLine;
|
|
34
|
+
exports.extendLine = extendLine;
|
|
35
|
+
exports.findCatalogElement = findCatalogElement;
|
|
36
|
+
exports.getAllArea = getAllArea;
|
|
37
|
+
exports.getAllAreaLines = getAllAreaLines;
|
|
38
|
+
exports.getAllCurSnap = getAllCurSnap;
|
|
39
|
+
exports.getAllHoleRect = getAllHoleRect;
|
|
40
|
+
exports.getAllItemSnap = getAllItemSnap;
|
|
41
|
+
exports.getAllItemSpecified = getAllItemSpecified;
|
|
42
|
+
exports.getAllItems = getAllItems;
|
|
43
|
+
exports.getAllLineSnap = getAllLineSnap;
|
|
44
|
+
exports.getAllLines = getAllLines;
|
|
45
|
+
exports.getCalcRectFromItem = getCalcRectFromItem;
|
|
46
|
+
exports.getCalcRectFromItem3D = getCalcRectFromItem3D;
|
|
47
|
+
exports.getCalcRectFromLine = getCalcRectFromLine;
|
|
48
|
+
exports.getCentroidOfPolygon = getCentroidOfPolygon;
|
|
49
|
+
exports.getHoleItems = getHoleItems;
|
|
50
|
+
exports.getInterSect = getInterSect;
|
|
51
|
+
exports.getLineInterSect = getLineInterSect;
|
|
52
|
+
exports.getNormaline = getNormaline;
|
|
53
|
+
exports.getRelatedLines = void 0;
|
|
54
|
+
exports.getRelatedVertices = getRelatedVertices;
|
|
55
|
+
exports.horizontalLine = horizontalLine;
|
|
56
|
+
exports.intersectRect = intersectRect;
|
|
57
|
+
exports.isBackWall = isBackWall;
|
|
58
|
+
exports.isFrontWall = isFrontWall;
|
|
59
|
+
exports.isLeftWall = isLeftWall;
|
|
60
|
+
exports.isPointInArea = isPointInArea;
|
|
61
|
+
exports.isPointInRect = isPointInRect;
|
|
62
|
+
exports.isPointOnLineSegment = isPointOnLineSegment;
|
|
63
|
+
exports.isRightWall = isRightWall;
|
|
64
|
+
exports.isSnappedLine = isSnappedLine;
|
|
65
|
+
exports.isSnappedSideLine = isSnappedSideLine;
|
|
66
|
+
exports.itemInfo = itemInfo;
|
|
67
|
+
exports.linePassingThroughTwoPoints = linePassingThroughTwoPoints;
|
|
68
|
+
exports.mapRange = mapRange;
|
|
69
|
+
exports.maxVertex = maxVertex;
|
|
70
|
+
exports.midPoint = midPoint;
|
|
71
|
+
exports.minVertex = minVertex;
|
|
72
|
+
exports.needSnap = needSnap;
|
|
73
|
+
exports.orderVertices = orderVertices;
|
|
74
|
+
exports.pointPositionOnLineSegment = pointPositionOnLineSegment;
|
|
75
|
+
exports.pointsDistance = pointsDistance;
|
|
76
|
+
exports.relationshipOfTwoOverlappedLines = relationshipOfTwoOverlappedLines;
|
|
77
|
+
exports.relationshipOfTwoOverlappedLines1 = relationshipOfTwoOverlappedLines1;
|
|
78
|
+
exports.relationshipOfTwoOverlappedLines2 = relationshipOfTwoOverlappedLines2;
|
|
79
|
+
exports.rotatePointAroundPoint = rotatePointAroundPoint;
|
|
80
|
+
exports.roundVertex = roundVertex;
|
|
81
|
+
exports.sameDistances = sameDistances;
|
|
82
|
+
exports.sameMDistances = sameMDistances;
|
|
83
|
+
exports.sameMPoints = sameMPoints;
|
|
84
|
+
exports.samePoints = samePoints;
|
|
85
|
+
exports.shrinkRect = shrinkRect;
|
|
86
|
+
exports.sinWithThreshold = sinWithThreshold;
|
|
87
|
+
exports.snapAngleByUnit = snapAngleByUnit;
|
|
88
|
+
exports.twoLineSegmentsIntersection = twoLineSegmentsIntersection;
|
|
89
|
+
exports.twoLinesIntersection = twoLinesIntersection;
|
|
90
|
+
exports.upcrossLine = upcrossLine;
|
|
91
|
+
exports.validInterSect = validInterSect;
|
|
92
|
+
exports.validSnap = validSnap;
|
|
93
|
+
exports.validateLineSnaps = validateLineSnaps;
|
|
94
|
+
exports.validateSnaps = validateSnaps;
|
|
95
|
+
exports.verticalLine = verticalLine;
|
|
96
|
+
exports.verticesDistance = verticesDistance;
|
|
97
|
+
exports.verticesMidPoint = verticesMidPoint;
|
|
98
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
99
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
100
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
101
|
+
var _math = require("./math.js");
|
|
102
|
+
var _constants = require("../constants");
|
|
103
|
+
var _convertUnitsLite = require("./convert-units-lite");
|
|
104
|
+
var Three = _interopRequireWildcard(require("three"));
|
|
105
|
+
var _utils = require("../components/viewer2d/utils.js");
|
|
106
|
+
var _helper = require("./helper.js");
|
|
107
|
+
var _export = require("./export.js");
|
|
108
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
6
109
|
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; }
|
|
7
|
-
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) {
|
|
8
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
9
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
10
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
110
|
+
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) { (0, _defineProperty2["default"])(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; }
|
|
11
111
|
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; } } }; }
|
|
12
|
-
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
13
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
14
112
|
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; } }
|
|
15
|
-
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; }
|
|
16
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
17
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
18
|
-
/** @description Determines the distance between two points
|
|
113
|
+
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; } /** @description Determines the distance between two points
|
|
19
114
|
* @param {number} x0 Vertex 0 x
|
|
20
115
|
* @param {number} y0 Vertex 0 y
|
|
21
116
|
* @param {number} x1 Vertex 1 x
|
|
22
117
|
* @param {number} y1 Vertex 1 y
|
|
23
118
|
* @return {number}
|
|
24
119
|
*/
|
|
25
|
-
|
|
26
|
-
import { BASE_CABINET_LAYOUTPOS, EPSILON, LINE_THICKNESS, MEPSILON, OVERLAP_INCLUDED, OVERLAP_LINK, OVERLAP_NONE, OVERLAP_SAME, OVERLAP_SOME, WALL_CABINET_LAYOUTPOS, UNIT_ANGLE, MIN_ANGLE_DISALLOW_DRAW_WALL } from "../constants";
|
|
27
|
-
import convert from 'convert-units';
|
|
28
|
-
import * as Three from 'three';
|
|
29
|
-
import { returnReplaceableDeepSearchType } from "../components/viewer2d/utils.js";
|
|
30
|
-
import { isEmpty } from "./helper.js";
|
|
31
|
-
import { MathUtils } from "./export.js";
|
|
32
|
-
export function compareVertices(v0, v1) {
|
|
120
|
+
function compareVertices(v0, v1) {
|
|
33
121
|
return v0.x === v1.x ? v0.y - v1.y : v0.x - v1.x;
|
|
34
122
|
}
|
|
35
|
-
|
|
123
|
+
function minVertex(v0, v1) {
|
|
36
124
|
return compareVertices(v0, v1) > 0 ? v1 : v0;
|
|
37
125
|
}
|
|
38
|
-
|
|
126
|
+
function maxVertex(v0, v1) {
|
|
39
127
|
return compareVertices(v0, v1) > 0 ? v0 : v1;
|
|
40
128
|
}
|
|
41
|
-
|
|
129
|
+
function orderVertices(vertices) {
|
|
42
130
|
return vertices.sort(compareVertices);
|
|
43
131
|
}
|
|
44
|
-
|
|
132
|
+
function pointsDistance(x0, y0, x1, y1) {
|
|
45
133
|
var diff_x = x0 - x1;
|
|
46
134
|
var diff_y = y0 - y1;
|
|
47
135
|
return Math.sqrt(diff_x * diff_x + diff_y * diff_y);
|
|
48
136
|
}
|
|
49
|
-
|
|
137
|
+
function verticesDistance(v1, v2) {
|
|
50
138
|
var x0 = v1.x,
|
|
51
139
|
y0 = v1.y;
|
|
52
140
|
var x1 = v2.x,
|
|
53
141
|
y1 = v2.y;
|
|
54
142
|
return pointsDistance(x0, y0, x1, y1);
|
|
55
143
|
}
|
|
56
|
-
|
|
144
|
+
function horizontalLine(y) {
|
|
57
145
|
return {
|
|
58
146
|
a: 0,
|
|
59
147
|
b: 1,
|
|
60
148
|
c: -y
|
|
61
149
|
};
|
|
62
150
|
}
|
|
63
|
-
|
|
64
|
-
return Math.abs(x - y) < EPSILON;
|
|
151
|
+
var almostEqual = exports.almostEqual = function almostEqual(x, y) {
|
|
152
|
+
return Math.abs(x - y) < _constants.EPSILON;
|
|
65
153
|
};
|
|
66
|
-
|
|
154
|
+
function verticalLine(x) {
|
|
67
155
|
return {
|
|
68
156
|
a: 1,
|
|
69
157
|
b: 0,
|
|
70
158
|
c: -x
|
|
71
159
|
};
|
|
72
160
|
}
|
|
73
|
-
|
|
161
|
+
function upcrossLine(x, y) {
|
|
74
162
|
return {
|
|
75
163
|
a: 1,
|
|
76
164
|
b: 1,
|
|
77
165
|
c: -x - y
|
|
78
166
|
};
|
|
79
167
|
}
|
|
80
|
-
|
|
168
|
+
function downcrossLine(x, y) {
|
|
81
169
|
return {
|
|
82
170
|
a: 1,
|
|
83
171
|
b: -1,
|
|
84
172
|
c: -x + y
|
|
85
173
|
};
|
|
86
174
|
}
|
|
87
|
-
|
|
175
|
+
function linePassingThroughTwoPoints(x1, y1, x2, y2) {
|
|
88
176
|
if (x1 === x2 && y1 == y2) throw new Error('Geometry error');
|
|
89
177
|
//if (x1 === x2) return verticalLine(x1);
|
|
90
178
|
//if (y1 === y2) return horizontalLine(y1);
|
|
@@ -95,18 +183,18 @@ export function linePassingThroughTwoPoints(x1, y1, x2, y2) {
|
|
|
95
183
|
c: y2 * x1 - x2 * y1
|
|
96
184
|
};
|
|
97
185
|
}
|
|
98
|
-
|
|
186
|
+
function getNormaline(x1, y1, x2, y2) {
|
|
99
187
|
var lineFunction = linePassingThroughTwoPoints(x1, y1, x2, y2);
|
|
100
188
|
return {
|
|
101
189
|
x: lineFunction.a / Math.sqrt(lineFunction.a * lineFunction.a + lineFunction.b * lineFunction.b),
|
|
102
190
|
y: lineFunction.b / Math.sqrt(lineFunction.a * lineFunction.a + lineFunction.b * lineFunction.b)
|
|
103
191
|
};
|
|
104
192
|
}
|
|
105
|
-
|
|
193
|
+
function distancePointFromLine(a, b, c, x, y) {
|
|
106
194
|
//https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line
|
|
107
|
-
return fAbs(a * x + b * y + c) / Math.sqrt(a * a + b * b);
|
|
195
|
+
return (0, _math.fAbs)(a * x + b * y + c) / Math.sqrt(a * a + b * b);
|
|
108
196
|
}
|
|
109
|
-
|
|
197
|
+
function closestPointFromLine(a, b, c, x, y) {
|
|
110
198
|
//https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line
|
|
111
199
|
var denom = a * a + b * b;
|
|
112
200
|
return {
|
|
@@ -124,7 +212,7 @@ export function closestPointFromLine(a, b, c, x, y) {
|
|
|
124
212
|
* @param {number} l costant of second line
|
|
125
213
|
* @return {object} {x,y} point's coordinates
|
|
126
214
|
*/
|
|
127
|
-
|
|
215
|
+
function twoLinesIntersection(a, b, c, j, k, l) {
|
|
128
216
|
var angularCoefficientsDiff = b * j - a * k;
|
|
129
217
|
if (angularCoefficientsDiff === 0) return undefined; //no intersection
|
|
130
218
|
|
|
@@ -135,10 +223,10 @@ export function twoLinesIntersection(a, b, c, j, k, l) {
|
|
|
135
223
|
y: y
|
|
136
224
|
};
|
|
137
225
|
}
|
|
138
|
-
|
|
226
|
+
function twoLineSegmentsIntersection(p1, p2, p3, p4) {
|
|
139
227
|
return _twoLineSegmentsIntersection(p1, p2, p3.toJS(), p4.toJS());
|
|
140
228
|
}
|
|
141
|
-
|
|
229
|
+
function _twoLineSegmentsIntersection(p1, p2, p3, p4) {
|
|
142
230
|
//https://github.com/psalaets/line-intersect/blob/master/lib/check-intersection.js
|
|
143
231
|
|
|
144
232
|
var x1 = p1.x,
|
|
@@ -152,8 +240,8 @@ export function _twoLineSegmentsIntersection(p1, p2, p3, p4) {
|
|
|
152
240
|
var denom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);
|
|
153
241
|
var numA = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3);
|
|
154
242
|
var numB = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3);
|
|
155
|
-
if (fAbs(denom) <= EPSILON) {
|
|
156
|
-
if (fAbs(numA) <= EPSILON && fAbs(numB) <= EPSILON) {
|
|
243
|
+
if ((0, _math.fAbs)(denom) <= _constants.EPSILON) {
|
|
244
|
+
if ((0, _math.fAbs)(numA) <= _constants.EPSILON && (0, _math.fAbs)(numB) <= _constants.EPSILON) {
|
|
157
245
|
var comparator = function comparator(pa, pb) {
|
|
158
246
|
return pa.x === pb.x ? pa.y - pb.y : pa.x - pb.x;
|
|
159
247
|
};
|
|
@@ -162,7 +250,7 @@ export function _twoLineSegmentsIntersection(p1, p2, p3, p4) {
|
|
|
162
250
|
var _sort = [line0, line1].sort(function (lineA, lineB) {
|
|
163
251
|
return comparator(lineA[0], lineB[0]);
|
|
164
252
|
}),
|
|
165
|
-
_sort2 =
|
|
253
|
+
_sort2 = (0, _slicedToArray2["default"])(_sort, 2),
|
|
166
254
|
lineSX = _sort2[0],
|
|
167
255
|
lineDX = _sort2[1];
|
|
168
256
|
comparator(lineSX[1], lineDX[0]) < 0 ? 'colinear' : 'none';
|
|
@@ -182,7 +270,7 @@ export function _twoLineSegmentsIntersection(p1, p2, p3, p4) {
|
|
|
182
270
|
}
|
|
183
271
|
var uA = numA / denom;
|
|
184
272
|
var uB = numB / denom;
|
|
185
|
-
if (uA >= 0 - EPSILON && uA <= 1 + EPSILON && uB >= 0 - EPSILON && uB <= 1 + EPSILON) {
|
|
273
|
+
if (uA >= 0 - _constants.EPSILON && uA <= 1 + _constants.EPSILON && uB >= 0 - _constants.EPSILON && uB <= 1 + _constants.EPSILON) {
|
|
186
274
|
var _point = {
|
|
187
275
|
x: x1 + uA * (x2 - x1),
|
|
188
276
|
y: y1 + uA * (y2 - y1)
|
|
@@ -196,7 +284,7 @@ export function _twoLineSegmentsIntersection(p1, p2, p3, p4) {
|
|
|
196
284
|
type: 'none'
|
|
197
285
|
};
|
|
198
286
|
}
|
|
199
|
-
|
|
287
|
+
function distancePointFromLineSegment(v1, v2, xp, yp) {
|
|
200
288
|
//http://stackoverflow.com/a/6853926/1398836
|
|
201
289
|
var x1 = v1.x,
|
|
202
290
|
y1 = v1.y;
|
|
@@ -239,8 +327,8 @@ export function distancePointFromLineSegment(v1, v2, xp, yp) {
|
|
|
239
327
|
* @param maxDistance {number} the epsilon value used for comparisons
|
|
240
328
|
* @returns {boolean} true if the point lies on the line segment false otherwise
|
|
241
329
|
*/
|
|
242
|
-
|
|
243
|
-
var maxDistance = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : EPSILON;
|
|
330
|
+
function isPointOnLineSegment(x1, y1, x2, y2, xp, yp) {
|
|
331
|
+
var maxDistance = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : _constants.EPSILON;
|
|
244
332
|
return distancePointFromLineSegment({
|
|
245
333
|
x: x1,
|
|
246
334
|
y: y1
|
|
@@ -249,7 +337,7 @@ export function isPointOnLineSegment(x1, y1, x2, y2, xp, yp) {
|
|
|
249
337
|
y: y2
|
|
250
338
|
}, xp, yp) <= maxDistance;
|
|
251
339
|
}
|
|
252
|
-
|
|
340
|
+
function closestPointFromLineSegment(x1, y1, x2, y2, xp, yp) {
|
|
253
341
|
if (x1 === x2) return {
|
|
254
342
|
x: x1,
|
|
255
343
|
y: yp
|
|
@@ -269,7 +357,7 @@ export function closestPointFromLineSegment(x1, y1, x2, y2, xp, yp) {
|
|
|
269
357
|
y: y
|
|
270
358
|
};
|
|
271
359
|
}
|
|
272
|
-
|
|
360
|
+
function pointPositionOnLineSegment(x1, y1, x2, y2, xp, yp) {
|
|
273
361
|
var length = pointsDistance(x1, y1, x2, y2);
|
|
274
362
|
var distance = pointsDistance(x1, y1, xp, yp);
|
|
275
363
|
var offset = distance / length;
|
|
@@ -279,16 +367,16 @@ export function pointPositionOnLineSegment(x1, y1, x2, y2, xp, yp) {
|
|
|
279
367
|
*/
|
|
280
368
|
return offset;
|
|
281
369
|
}
|
|
282
|
-
|
|
370
|
+
function mapRange(value, low1, high1, low2, high2) {
|
|
283
371
|
return low2 + (high2 - low2) * (value - low1) / (high1 - low1);
|
|
284
372
|
}
|
|
285
|
-
|
|
373
|
+
function angleBetweenTwoPointsAndOrigin(x1, y1, x2, y2) {
|
|
286
374
|
return -Math.atan2(y1 - y2, x2 - x1) * 180 / Math.PI;
|
|
287
375
|
}
|
|
288
|
-
|
|
376
|
+
function angleBetweenTwoPoints(x1, y1, x2, y2) {
|
|
289
377
|
return Math.atan2(y2 - y1, x2 - x1);
|
|
290
378
|
}
|
|
291
|
-
|
|
379
|
+
function angleBetweenTwoLines(line, drawingLine, vertices) {
|
|
292
380
|
var points = [];
|
|
293
381
|
|
|
294
382
|
// safety guards
|
|
@@ -346,7 +434,7 @@ export function angleBetweenTwoLines(line, drawingLine, vertices) {
|
|
|
346
434
|
var v = vertices === null || vertices === void 0 ? void 0 : vertices[idx];
|
|
347
435
|
return v ? new Three.Vector2(v.x, v.y) : new Three.Vector2(0, 0);
|
|
348
436
|
}),
|
|
349
|
-
_points$slice$map2 =
|
|
437
|
+
_points$slice$map2 = (0, _slicedToArray2["default"])(_points$slice$map, 3),
|
|
350
438
|
c = _points$slice$map2[0],
|
|
351
439
|
p1 = _points$slice$map2[1],
|
|
352
440
|
p2 = _points$slice$map2[2];
|
|
@@ -354,7 +442,7 @@ export function angleBetweenTwoLines(line, drawingLine, vertices) {
|
|
|
354
442
|
var vec2 = p2.clone().sub(c).normalize();
|
|
355
443
|
return Math.floor(vec1.angle() * 180 / Math.PI - vec2.angle() * 180 / Math.PI + 0.5);
|
|
356
444
|
}
|
|
357
|
-
|
|
445
|
+
var getRelatedLines = exports.getRelatedLines = function getRelatedLines(tlines, drawingLine, vertices, lines) {
|
|
358
446
|
var exceptLineId = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
|
|
359
447
|
if (!(drawingLine !== null && drawingLine !== void 0 && drawingLine.vertices) || !Array.isArray(drawingLine.vertices)) return;
|
|
360
448
|
var seen = new Set();
|
|
@@ -370,7 +458,7 @@ export var getRelatedLines = function getRelatedLines(tlines, drawingLine, verti
|
|
|
370
458
|
try {
|
|
371
459
|
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
372
460
|
var lineId = _step5.value;
|
|
373
|
-
if (lineId !== drawingLine.id && lineId !== exceptLineId && !isEmpty(lines === null || lines === void 0 ? void 0 : lines[lineId]) && !seen.has(lineId)) {
|
|
461
|
+
if (lineId !== drawingLine.id && lineId !== exceptLineId && !(0, _helper.isEmpty)(lines === null || lines === void 0 ? void 0 : lines[lineId]) && !seen.has(lineId)) {
|
|
374
462
|
seen.add(lineId);
|
|
375
463
|
tlines.push(lines[lineId]);
|
|
376
464
|
}
|
|
@@ -387,12 +475,12 @@ export var getRelatedLines = function getRelatedLines(tlines, drawingLine, verti
|
|
|
387
475
|
_iterator4.f();
|
|
388
476
|
}
|
|
389
477
|
};
|
|
390
|
-
|
|
478
|
+
function snapAngleByUnit(lineAngle, vertices, drawingLine, x, y, dragVertexId) {
|
|
391
479
|
var tx, ty;
|
|
392
480
|
var absAngle = Math.abs(lineAngle);
|
|
393
481
|
// angle snapping as a value of UNIT_ANGLE
|
|
394
|
-
var rest = absAngle % UNIT_ANGLE;
|
|
395
|
-
var missAngle = UNIT_ANGLE - rest;
|
|
482
|
+
var rest = absAngle % _constants.UNIT_ANGLE;
|
|
483
|
+
var missAngle = _constants.UNIT_ANGLE - rest;
|
|
396
484
|
// the origin point of rotation(snapping)
|
|
397
485
|
var originVerId = drawingLine.vertices.findIndex(function (vertice) {
|
|
398
486
|
return vertice !== dragVertexId;
|
|
@@ -401,7 +489,7 @@ export function snapAngleByUnit(lineAngle, vertices, drawingLine, x, y, dragVert
|
|
|
401
489
|
var ox = vertices[originVerId].x;
|
|
402
490
|
var oy = vertices[originVerId].y;
|
|
403
491
|
// check whether the line is snapped to before point.
|
|
404
|
-
if (rest <= UNIT_ANGLE / 2) {
|
|
492
|
+
if (rest <= _constants.UNIT_ANGLE / 2) {
|
|
405
493
|
// determine the direction of rotation.
|
|
406
494
|
rest = lineAngle > 0 ? rest : -rest;
|
|
407
495
|
// rotate the current point to last point around the first point of drawing line.
|
|
@@ -409,7 +497,7 @@ export function snapAngleByUnit(lineAngle, vertices, drawingLine, x, y, dragVert
|
|
|
409
497
|
ty = rotatePointAroundPoint(x, y, ox, oy, rest).y;
|
|
410
498
|
}
|
|
411
499
|
// check whether the line is snapped to next new point.
|
|
412
|
-
else if (rest > UNIT_ANGLE / 2) {
|
|
500
|
+
else if (rest > _constants.UNIT_ANGLE / 2) {
|
|
413
501
|
// determine the direction of rotation.
|
|
414
502
|
missAngle = lineAngle > 0 ? -missAngle : missAngle;
|
|
415
503
|
// rotate the current point to last point around the first point of drawing line.
|
|
@@ -422,30 +510,30 @@ export function snapAngleByUnit(lineAngle, vertices, drawingLine, x, y, dragVert
|
|
|
422
510
|
};
|
|
423
511
|
return resPoint;
|
|
424
512
|
}
|
|
425
|
-
|
|
513
|
+
function absAngleBetweenTwoPoints(x1, y1, x2, y2) {
|
|
426
514
|
return Math.atan2(y2 - y1, Math.abs(x2 - x1));
|
|
427
515
|
}
|
|
428
|
-
|
|
516
|
+
function samePoints(_ref, _ref2) {
|
|
429
517
|
var x1 = _ref.x,
|
|
430
518
|
y1 = _ref.y;
|
|
431
519
|
var x2 = _ref2.x,
|
|
432
520
|
y2 = _ref2.y;
|
|
433
|
-
return fAbs(x1 - x2) <= EPSILON && fAbs(y1 - y2) <= EPSILON;
|
|
521
|
+
return (0, _math.fAbs)(x1 - x2) <= _constants.EPSILON && (0, _math.fAbs)(y1 - y2) <= _constants.EPSILON;
|
|
434
522
|
}
|
|
435
|
-
|
|
436
|
-
return fAbs(dis1 - dis2) <= EPSILON;
|
|
523
|
+
function sameDistances(dis1, dis2) {
|
|
524
|
+
return (0, _math.fAbs)(dis1 - dis2) <= _constants.EPSILON;
|
|
437
525
|
}
|
|
438
|
-
|
|
526
|
+
function sameMPoints(_ref3, _ref4) {
|
|
439
527
|
var x1 = _ref3.x,
|
|
440
528
|
y1 = _ref3.y;
|
|
441
529
|
var x2 = _ref4.x,
|
|
442
530
|
y2 = _ref4.y;
|
|
443
|
-
return fAbs(x1 - x2) <= MEPSILON && fAbs(y1 - y2) <= MEPSILON;
|
|
531
|
+
return (0, _math.fAbs)(x1 - x2) <= _constants.MEPSILON && (0, _math.fAbs)(y1 - y2) <= _constants.MEPSILON;
|
|
444
532
|
}
|
|
445
|
-
|
|
446
|
-
return fAbs(dis1 - dis2) <= MEPSILON;
|
|
533
|
+
function sameMDistances(dis1, dis2) {
|
|
534
|
+
return (0, _math.fAbs)(dis1 - dis2) <= _constants.MEPSILON;
|
|
447
535
|
}
|
|
448
|
-
|
|
536
|
+
function isPointInRect(rect, point) {
|
|
449
537
|
var result = true;
|
|
450
538
|
for (var i = 0; i < rect.length; i++) {
|
|
451
539
|
var pos1 = rect[i];
|
|
@@ -465,23 +553,23 @@ export function isPointInRect(rect, point) {
|
|
|
465
553
|
* @param {number} newDistance New line length
|
|
466
554
|
* @return {object}
|
|
467
555
|
*/
|
|
468
|
-
|
|
556
|
+
function extendLine(x1, y1, x2, y2, newDistance) {
|
|
469
557
|
var precision = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 6;
|
|
470
558
|
var rad = angleBetweenTwoPoints(x1, y1, x2, y2);
|
|
471
559
|
return {
|
|
472
|
-
x: toFixedFloat(x1 + Math.cos(rad) * newDistance, precision),
|
|
473
|
-
y: toFixedFloat(y1 + Math.sin(rad) * newDistance, precision)
|
|
560
|
+
x: (0, _math.toFixedFloat)(x1 + Math.cos(rad) * newDistance, precision),
|
|
561
|
+
y: (0, _math.toFixedFloat)(y1 + Math.sin(rad) * newDistance, precision)
|
|
474
562
|
};
|
|
475
563
|
}
|
|
476
|
-
|
|
564
|
+
function roundVertex(vertex) {
|
|
477
565
|
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 6;
|
|
478
|
-
vertex.set('x', toFixedFloat(vertex.get('x'), precision));
|
|
479
|
-
vertex.set('y', toFixedFloat(vertex.get('y'), precision));
|
|
566
|
+
vertex.set('x', (0, _math.toFixedFloat)(vertex.get('x'), precision));
|
|
567
|
+
vertex.set('y', (0, _math.toFixedFloat)(vertex.get('y'), precision));
|
|
480
568
|
return vertex;
|
|
481
569
|
}
|
|
482
570
|
|
|
483
571
|
//https://github.com/MartyWallace/PolyK
|
|
484
|
-
|
|
572
|
+
function ContainsPoint(polygon, pointX, pointY) {
|
|
485
573
|
var n = polygon.length >> 1;
|
|
486
574
|
var ax, lup;
|
|
487
575
|
var ay = polygon[2 * n - 3] - pointY;
|
|
@@ -520,21 +608,21 @@ export function ContainsPoint(polygon, pointX, pointY) {
|
|
|
520
608
|
}
|
|
521
609
|
return (depth & 1) === 1;
|
|
522
610
|
}
|
|
523
|
-
|
|
611
|
+
function cosWithThreshold(alpha, threshold) {
|
|
524
612
|
var cos = Math.cos(alpha);
|
|
525
613
|
return cos < threshold ? 0 : cos;
|
|
526
614
|
}
|
|
527
|
-
|
|
615
|
+
function sinWithThreshold(alpha, threshold) {
|
|
528
616
|
var sin = Math.sin(alpha);
|
|
529
617
|
return sin < threshold ? 0 : sin;
|
|
530
618
|
}
|
|
531
|
-
|
|
619
|
+
function midPoint(x1, y1, x2, y2) {
|
|
532
620
|
return {
|
|
533
621
|
x: (x1 + x2) / 2,
|
|
534
622
|
y: (y1 + y2) / 2
|
|
535
623
|
};
|
|
536
624
|
}
|
|
537
|
-
|
|
625
|
+
function verticesMidPoint(verticesArray) {
|
|
538
626
|
var res = verticesArray.reduce(function (incr, vertex) {
|
|
539
627
|
return {
|
|
540
628
|
x: incr.x + vertex.x,
|
|
@@ -549,7 +637,7 @@ export function verticesMidPoint(verticesArray) {
|
|
|
549
637
|
y: res.y / verticesArray.length
|
|
550
638
|
};
|
|
551
639
|
}
|
|
552
|
-
|
|
640
|
+
function rotatePointAroundPoint(px, py, ox, oy, theta) {
|
|
553
641
|
var thetaRad = theta * Math.PI / 180;
|
|
554
642
|
var cos = Math.cos(thetaRad);
|
|
555
643
|
var sin = Math.sin(thetaRad);
|
|
@@ -583,7 +671,7 @@ function itemrectInfo(x, y, rotRad, size, layoutpos, is_corner) {
|
|
|
583
671
|
is_corner: is_corner
|
|
584
672
|
};
|
|
585
673
|
}
|
|
586
|
-
|
|
674
|
+
function getCalcRectFromItem(item) {
|
|
587
675
|
var itemInfo;
|
|
588
676
|
if (item === undefined) itemInfo = [];else itemInfo = item.item;
|
|
589
677
|
var x = item.pos.x;
|
|
@@ -611,7 +699,7 @@ export function getCalcRectFromItem(item) {
|
|
|
611
699
|
itemInfo: itemInfo
|
|
612
700
|
};
|
|
613
701
|
}
|
|
614
|
-
|
|
702
|
+
function getCalcRectFromItem3D(item) {
|
|
615
703
|
var itemInfo;
|
|
616
704
|
if (item === undefined) itemInfo = [];else itemInfo = item.item;
|
|
617
705
|
var x = item.pos.x;
|
|
@@ -639,7 +727,7 @@ export function getCalcRectFromItem3D(item) {
|
|
|
639
727
|
itemInfo: itemInfo
|
|
640
728
|
};
|
|
641
729
|
}
|
|
642
|
-
|
|
730
|
+
function getAllItems(scene, catalog, allLineRects) {
|
|
643
731
|
var layerID = scene.selectedLayer;
|
|
644
732
|
var layer = scene.layers.get(layerID);
|
|
645
733
|
var curiteminfo;
|
|
@@ -651,7 +739,7 @@ export function getAllItems(scene, catalog, allLineRects) {
|
|
|
651
739
|
selectedItem = layer.getIn(['items', layer.selected.items.get(0)]);
|
|
652
740
|
var catid = selectedItem.type;
|
|
653
741
|
var cat = catalog.elements[catid];
|
|
654
|
-
if (!cat) cat = catalog.elements[returnReplaceableDeepSearchType(catid)];
|
|
742
|
+
if (!cat) cat = catalog.elements[(0, _utils.returnReplaceableDeepSearchType)(catid)];
|
|
655
743
|
currentItem = {
|
|
656
744
|
selectedItem: selectedItem,
|
|
657
745
|
cat: cat
|
|
@@ -668,7 +756,7 @@ export function getAllItems(scene, catalog, allLineRects) {
|
|
|
668
756
|
var catid = item.type;
|
|
669
757
|
var cat = catalog.elements[catid];
|
|
670
758
|
if (!cat) {
|
|
671
|
-
cat = catalog.elements[returnReplaceableDeepSearchType(catid)];
|
|
759
|
+
cat = catalog.elements[(0, _utils.returnReplaceableDeepSearchType)(catid)];
|
|
672
760
|
}
|
|
673
761
|
var sizeinfo = [];
|
|
674
762
|
var width, height, depth;
|
|
@@ -684,9 +772,9 @@ export function getAllItems(scene, catalog, allLineRects) {
|
|
|
684
772
|
layoutpos: cat && cat.info.layoutpos,
|
|
685
773
|
is_corner: cat && cat.info.is_corner
|
|
686
774
|
});
|
|
687
|
-
width = convert(sizeinfo.width).from(sizeinfo.widthUnit).to(scene.unit);
|
|
688
|
-
height = convert(sizeinfo.depth).from(sizeinfo.depthUnit).to(scene.unit);
|
|
689
|
-
depth = convert(sizeinfo.height).from(sizeinfo.heightUnit).to(scene.unit);
|
|
775
|
+
width = (0, _convertUnitsLite.convert)(sizeinfo.width).from(sizeinfo.widthUnit).to(scene.unit);
|
|
776
|
+
height = (0, _convertUnitsLite.convert)(sizeinfo.depth).from(sizeinfo.depthUnit).to(scene.unit);
|
|
777
|
+
depth = (0, _convertUnitsLite.convert)(sizeinfo.height).from(sizeinfo.heightUnit).to(scene.unit);
|
|
690
778
|
val.size = {
|
|
691
779
|
width: width,
|
|
692
780
|
height: height,
|
|
@@ -719,7 +807,7 @@ export function getAllItems(scene, catalog, allLineRects) {
|
|
|
719
807
|
otherItems: otherItems
|
|
720
808
|
};
|
|
721
809
|
}
|
|
722
|
-
|
|
810
|
+
function getAllItemSpecified(scene, catalog, filter) {
|
|
723
811
|
var _scene$layers, _scene$layers$get;
|
|
724
812
|
var layerID = scene === null || scene === void 0 ? void 0 : scene.selectedLayer;
|
|
725
813
|
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);
|
|
@@ -745,7 +833,7 @@ export function getAllItemSpecified(scene, catalog, filter) {
|
|
|
745
833
|
var getSize = function getSize(key) {
|
|
746
834
|
var _props$getIn;
|
|
747
835
|
var length = props === null || props === void 0 || (_props$getIn = props.getIn) === null || _props$getIn === void 0 ? void 0 : _props$getIn.call(props, [key, '_length']);
|
|
748
|
-
return length != null ? convert(length).from('in').to(scene.unit) : 0;
|
|
836
|
+
return length != null ? (0, _convertUnitsLite.convert)(length).from('in').to(scene.unit) : 0;
|
|
749
837
|
};
|
|
750
838
|
val.size = {
|
|
751
839
|
width: getSize('width'),
|
|
@@ -778,13 +866,13 @@ export function getAllItemSpecified(scene, catalog, filter) {
|
|
|
778
866
|
others: iteminfo
|
|
779
867
|
};
|
|
780
868
|
}
|
|
781
|
-
|
|
869
|
+
function findCatalogElement(catalog, elementName) {
|
|
782
870
|
if (!elementName || !catalog) return null;
|
|
783
871
|
var variants = [elementName, elementName.toLowerCase()];
|
|
784
872
|
var deepVariants = variants.map(function (v) {
|
|
785
|
-
return returnReplaceableDeepSearchType(v);
|
|
873
|
+
return (0, _utils.returnReplaceableDeepSearchType)(v);
|
|
786
874
|
}).filter(Boolean);
|
|
787
|
-
var allCandidates = [].concat(variants,
|
|
875
|
+
var allCandidates = [].concat(variants, (0, _toConsumableArray2["default"])(deepVariants));
|
|
788
876
|
var getElement = function getElement(catid) {
|
|
789
877
|
if (!catid) return null;
|
|
790
878
|
|
|
@@ -814,7 +902,7 @@ export function findCatalogElement(catalog, elementName) {
|
|
|
814
902
|
}
|
|
815
903
|
return null;
|
|
816
904
|
}
|
|
817
|
-
|
|
905
|
+
function isSnappedLine(calcrect, allLineRects) {
|
|
818
906
|
if (allLineRects === undefined) return false;
|
|
819
907
|
var r2 = calcrect.rect[2];
|
|
820
908
|
var r3 = calcrect.rect[3];
|
|
@@ -822,18 +910,18 @@ export function isSnappedLine(calcrect, allLineRects) {
|
|
|
822
910
|
var l2 = linerect.rect[2];
|
|
823
911
|
var l3 = linerect.rect[3];
|
|
824
912
|
var delta = verticesDistance(l2, r3) + verticesDistance(r3, r2) + verticesDistance(r2, l3) - verticesDistance(l3, l2);
|
|
825
|
-
if (delta < EPSILON) {
|
|
913
|
+
if (delta < _constants.EPSILON) {
|
|
826
914
|
return true;
|
|
827
915
|
} else {
|
|
828
916
|
l2 = linerect.rect[3];
|
|
829
917
|
l3 = linerect.rect[2];
|
|
830
918
|
delta = verticesDistance(l2, r3) + verticesDistance(r3, r2) + verticesDistance(r2, l3) - verticesDistance(l3, l2);
|
|
831
|
-
return delta < EPSILON;
|
|
919
|
+
return delta < _constants.EPSILON;
|
|
832
920
|
}
|
|
833
921
|
});
|
|
834
922
|
return result;
|
|
835
923
|
}
|
|
836
|
-
|
|
924
|
+
function isSnappedSideLine(calcrect, allLineRects) {
|
|
837
925
|
if (allLineRects === undefined) return 0;
|
|
838
926
|
var r2 = calcrect.rect[1];
|
|
839
927
|
var r3 = calcrect.rect[2];
|
|
@@ -841,13 +929,13 @@ export function isSnappedSideLine(calcrect, allLineRects) {
|
|
|
841
929
|
var l2 = linerect.rect[2];
|
|
842
930
|
var l3 = linerect.rect[3];
|
|
843
931
|
var delta = verticesDistance(l2, r3) + verticesDistance(r3, r2) + verticesDistance(r2, l3) - verticesDistance(l3, l2);
|
|
844
|
-
return delta < EPSILON;
|
|
932
|
+
return delta < _constants.EPSILON;
|
|
845
933
|
});
|
|
846
934
|
return result;
|
|
847
935
|
}
|
|
848
936
|
|
|
849
937
|
/** Calculate candidate positions */
|
|
850
|
-
|
|
938
|
+
function getAllItemSnap(allItemRects) {
|
|
851
939
|
var allItemSnap = [];
|
|
852
940
|
var cur = allItemRects.cur;
|
|
853
941
|
|
|
@@ -913,7 +1001,7 @@ export function getAllItemSnap(allItemRects) {
|
|
|
913
1001
|
});
|
|
914
1002
|
return allItemSnap;
|
|
915
1003
|
}
|
|
916
|
-
|
|
1004
|
+
function getAllArea(layer) {
|
|
917
1005
|
var allAreaLines = [];
|
|
918
1006
|
var allLines = [];
|
|
919
1007
|
var verticesArray = [];
|
|
@@ -940,11 +1028,11 @@ export function getAllArea(layer) {
|
|
|
940
1028
|
}
|
|
941
1029
|
|
|
942
1030
|
/** Get all lines of the scene */
|
|
943
|
-
|
|
1031
|
+
function getAllLines(layer) {
|
|
944
1032
|
var allAreaLines = getAllAreaLines(layer);
|
|
945
1033
|
var allLines = [];
|
|
946
1034
|
//let allNonAreaLines = [];
|
|
947
|
-
var thick = LINE_THICKNESS / 2;
|
|
1035
|
+
var thick = _constants.LINE_THICKNESS / 2;
|
|
948
1036
|
layer.lines.forEach(function (line) {
|
|
949
1037
|
var i = containLine(allAreaLines, line);
|
|
950
1038
|
// let thick = line.properties.getIn(['thickness', 'length']);
|
|
@@ -998,7 +1086,7 @@ export function getAllLines(layer) {
|
|
|
998
1086
|
}
|
|
999
1087
|
|
|
1000
1088
|
/** Get lines that wraps the area */
|
|
1001
|
-
|
|
1089
|
+
function getAllAreaLines(layer) {
|
|
1002
1090
|
var areainfo = [];
|
|
1003
1091
|
layer.areas.forEach(function (area) {
|
|
1004
1092
|
var sz = area.vertices.size;
|
|
@@ -1008,7 +1096,7 @@ export function getAllAreaLines(layer) {
|
|
|
1008
1096
|
});
|
|
1009
1097
|
return areainfo;
|
|
1010
1098
|
}
|
|
1011
|
-
|
|
1099
|
+
function containLine(lines, line) {
|
|
1012
1100
|
// lines: [array]
|
|
1013
1101
|
var sz = lines.length;
|
|
1014
1102
|
for (var i = 0; i < sz; i++) {
|
|
@@ -1019,7 +1107,7 @@ export function containLine(lines, line) {
|
|
|
1019
1107
|
}
|
|
1020
1108
|
return -1;
|
|
1021
1109
|
}
|
|
1022
|
-
|
|
1110
|
+
function buildRectFromLines(layer, lines) {
|
|
1023
1111
|
var rect = [];
|
|
1024
1112
|
lines.forEach(function (line) {
|
|
1025
1113
|
var vxys = []; // 0: x0, 1: y0, 2: x1, 3: y1
|
|
@@ -1037,7 +1125,7 @@ export function buildRectFromLines(layer, lines) {
|
|
|
1037
1125
|
});
|
|
1038
1126
|
return rect;
|
|
1039
1127
|
}
|
|
1040
|
-
|
|
1128
|
+
function getRelatedVertices(x0, y0, x1, y1, layer) {
|
|
1041
1129
|
var verticesArray = [];
|
|
1042
1130
|
var mapVertIDtoIndex = {};
|
|
1043
1131
|
layer.vertices.forEach(function (vertex) {
|
|
@@ -1057,7 +1145,7 @@ export function getRelatedVertices(x0, y0, x1, y1, layer) {
|
|
|
1057
1145
|
x: verticesArray[mapVertIDtoIndex[vertID1]][0],
|
|
1058
1146
|
y: verticesArray[mapVertIDtoIndex[vertID1]][1]
|
|
1059
1147
|
};
|
|
1060
|
-
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) {
|
|
1148
|
+
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) {
|
|
1061
1149
|
if (line.relatedVertices.size == 2) {
|
|
1062
1150
|
var relPt0 = point(x0, y0);
|
|
1063
1151
|
var relPt1 = point(x1, y1);
|
|
@@ -1073,7 +1161,7 @@ export function getRelatedVertices(x0, y0, x1, y1, layer) {
|
|
|
1073
1161
|
});
|
|
1074
1162
|
return relVerts;
|
|
1075
1163
|
}
|
|
1076
|
-
|
|
1164
|
+
function getCalcRectFromLine(x0, y0, x1, y1, thick, layer) {
|
|
1077
1165
|
// get line from vertex coordinate
|
|
1078
1166
|
var relVerts = getRelatedVertices(x0, y0, x1, y1, layer);
|
|
1079
1167
|
var dx = x1 - x0;
|
|
@@ -1119,7 +1207,7 @@ export function getCalcRectFromLine(x0, y0, x1, y1, thick, layer) {
|
|
|
1119
1207
|
}
|
|
1120
1208
|
};
|
|
1121
1209
|
}
|
|
1122
|
-
|
|
1210
|
+
function getAllLineSnap(allLineRects, curItemRect) {
|
|
1123
1211
|
var allLineSnap = [];
|
|
1124
1212
|
var cur = curItemRect;
|
|
1125
1213
|
if (cur === undefined || cur === null) return;else allLineRects.forEach(function (rect) {
|
|
@@ -1143,7 +1231,7 @@ export function getAllLineSnap(allLineRects, curItemRect) {
|
|
|
1143
1231
|
});
|
|
1144
1232
|
return allLineSnap;
|
|
1145
1233
|
}
|
|
1146
|
-
|
|
1234
|
+
function validateSnaps(allSnaps, allRects) {
|
|
1147
1235
|
var validSnaps = [];
|
|
1148
1236
|
if (allSnaps !== undefined && allSnaps !== null && allSnaps.length > 0) allSnaps.forEach(function (snap) {
|
|
1149
1237
|
if (validSnap(snap, allRects)) {
|
|
@@ -1152,7 +1240,7 @@ export function validateSnaps(allSnaps, allRects) {
|
|
|
1152
1240
|
});
|
|
1153
1241
|
return validSnaps;
|
|
1154
1242
|
}
|
|
1155
|
-
|
|
1243
|
+
function validateLineSnaps(allSnaps, allItemSnap, allLineSnap, allItemRects, allLineRects, allRects) {
|
|
1156
1244
|
var validSnaps = [];
|
|
1157
1245
|
allSnaps.forEach(function (snap) {
|
|
1158
1246
|
if (validSnap(snap, allRects)) {
|
|
@@ -1168,13 +1256,13 @@ export function validateLineSnaps(allSnaps, allItemSnap, allLineSnap, allItemRec
|
|
|
1168
1256
|
});
|
|
1169
1257
|
return validSnaps;
|
|
1170
1258
|
}
|
|
1171
|
-
|
|
1259
|
+
function validSnap(snap, rects) {
|
|
1172
1260
|
var snaprect = getCalcRectFromItem(snap);
|
|
1173
1261
|
return rects.every(function (rect) {
|
|
1174
1262
|
return !intersectRect(rect.rect, snaprect.rect);
|
|
1175
1263
|
});
|
|
1176
1264
|
}
|
|
1177
|
-
|
|
1265
|
+
function itemInfo(x, y, rotRad, size) {
|
|
1178
1266
|
return {
|
|
1179
1267
|
pos: {
|
|
1180
1268
|
x: x,
|
|
@@ -1184,7 +1272,7 @@ export function itemInfo(x, y, rotRad, size) {
|
|
|
1184
1272
|
size: size
|
|
1185
1273
|
};
|
|
1186
1274
|
}
|
|
1187
|
-
|
|
1275
|
+
function intersectRect(rect1, rect2) {
|
|
1188
1276
|
var ret = false;
|
|
1189
1277
|
rect1 = shrinkRect(rect1);
|
|
1190
1278
|
rect2 = shrinkRect(rect2);
|
|
@@ -1197,7 +1285,7 @@ export function intersectRect(rect1, rect2) {
|
|
|
1197
1285
|
});
|
|
1198
1286
|
return ret;
|
|
1199
1287
|
}
|
|
1200
|
-
|
|
1288
|
+
function containPointInRect(point, rect) {
|
|
1201
1289
|
// true: contain, false: not contain
|
|
1202
1290
|
for (var i = 0; i < rect.length; i++) {
|
|
1203
1291
|
var ni = (i + 1) % rect.length;
|
|
@@ -1207,16 +1295,16 @@ export function containPointInRect(point, rect) {
|
|
|
1207
1295
|
}
|
|
1208
1296
|
return true;
|
|
1209
1297
|
}
|
|
1210
|
-
|
|
1298
|
+
function diff(v0, v1) {
|
|
1211
1299
|
return {
|
|
1212
1300
|
x: v0.x - v1.x,
|
|
1213
1301
|
y: v0.y - v1.y
|
|
1214
1302
|
};
|
|
1215
1303
|
}
|
|
1216
|
-
|
|
1304
|
+
function crossprod(v0, v1) {
|
|
1217
1305
|
return v0.x * v1.y - v0.y * v1.x;
|
|
1218
1306
|
}
|
|
1219
|
-
|
|
1307
|
+
function shrinkRect(rect) {
|
|
1220
1308
|
var v02x = rect[2].x - rect[0].x;
|
|
1221
1309
|
var v02y = rect[2].y - rect[0].y;
|
|
1222
1310
|
var d02 = Math.sqrt(v02x * v02x + v02y * v02y);
|
|
@@ -1229,7 +1317,7 @@ export function shrinkRect(rect) {
|
|
|
1229
1317
|
var o13y = v13y / d13 * 0.1;
|
|
1230
1318
|
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)];
|
|
1231
1319
|
}
|
|
1232
|
-
|
|
1320
|
+
function getInterSect(shape1, shape2) {
|
|
1233
1321
|
// return result of intersect of two shape
|
|
1234
1322
|
var count = 0;
|
|
1235
1323
|
for (var i = 0; i < shape1.length; i++) {
|
|
@@ -1259,7 +1347,7 @@ export function getInterSect(shape1, shape2) {
|
|
|
1259
1347
|
}
|
|
1260
1348
|
return false;
|
|
1261
1349
|
}
|
|
1262
|
-
|
|
1350
|
+
function getLineInterSect(s1x, s1y, e1x, e1y, s2x, s2y, e2x, e2y) {
|
|
1263
1351
|
var ax = s1x;
|
|
1264
1352
|
var ay = s1y;
|
|
1265
1353
|
var bx = e1x - s1x;
|
|
@@ -1304,7 +1392,7 @@ export function getLineInterSect(s1x, s1y, e1x, e1y, s2x, s2y, e2x, e2y) {
|
|
|
1304
1392
|
return ret;
|
|
1305
1393
|
}
|
|
1306
1394
|
}
|
|
1307
|
-
|
|
1395
|
+
function isPointInArea(allArea, pt) {
|
|
1308
1396
|
var x = pt.x;
|
|
1309
1397
|
var y = pt.y;
|
|
1310
1398
|
var result = false;
|
|
@@ -1324,7 +1412,7 @@ export function isPointInArea(allArea, pt) {
|
|
|
1324
1412
|
x: x1 - x,
|
|
1325
1413
|
y: y1 - y
|
|
1326
1414
|
};
|
|
1327
|
-
if (Math.abs(v0.x) < EPSILON && Math.abs(v0.y) < EPSILON)
|
|
1415
|
+
if (Math.abs(v0.x) < _constants.EPSILON && Math.abs(v0.y) < _constants.EPSILON)
|
|
1328
1416
|
// check if pt is area point
|
|
1329
1417
|
return true;
|
|
1330
1418
|
|
|
@@ -1337,18 +1425,18 @@ export function isPointInArea(allArea, pt) {
|
|
|
1337
1425
|
};
|
|
1338
1426
|
var xE = x0 + vPt.x * lineLen;
|
|
1339
1427
|
var yE = y0 + vPt.y * lineLen;
|
|
1340
|
-
if (v0Len <= lineLen && Math.abs(xE - x1) < EPSILON && Math.abs(yE - y1) < EPSILON) return true;
|
|
1428
|
+
if (v0Len <= lineLen && Math.abs(xE - x1) < _constants.EPSILON && Math.abs(yE - y1) < _constants.EPSILON) return true;
|
|
1341
1429
|
alpha = Math.atan2(v0.x * v1.y - v1.x * v0.y, v0.x * v1.x + v0.y * v1.y);
|
|
1342
1430
|
sum += alpha;
|
|
1343
1431
|
}
|
|
1344
|
-
if (Math.abs(Math.abs(sum) - Math.PI * 2) < EPSILON) return true;
|
|
1432
|
+
if (Math.abs(Math.abs(sum) - Math.PI * 2) < _constants.EPSILON) return true;
|
|
1345
1433
|
});
|
|
1346
1434
|
return result;
|
|
1347
1435
|
}
|
|
1348
|
-
|
|
1436
|
+
function calcSnap(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, allAreaLines) {
|
|
1349
1437
|
return calcSnap2(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, allAreaLines);
|
|
1350
1438
|
}
|
|
1351
|
-
|
|
1439
|
+
function calcCreateSnap(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, polygonPoint) {
|
|
1352
1440
|
// Validate required input and guard against missing `.cur`
|
|
1353
1441
|
if (!allItemRect || !allItemRect.cur) return;
|
|
1354
1442
|
var cur = allItemRect.cur; // safe alias
|
|
@@ -1406,7 +1494,7 @@ export function calcCreateSnap(allItemRect, allItemSnap, allLineRects, allLineSn
|
|
|
1406
1494
|
}
|
|
1407
1495
|
|
|
1408
1496
|
////////////
|
|
1409
|
-
|
|
1497
|
+
function calcSnap1(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y) {
|
|
1410
1498
|
var cx = allItemRect.cur.pos.x;
|
|
1411
1499
|
var cy = allItemRect.cur.pos.y;
|
|
1412
1500
|
var nx = x;
|
|
@@ -1450,7 +1538,7 @@ export function calcSnap1(allItemRect, allItemSnap, allLineRects, allLineSnap, a
|
|
|
1450
1538
|
}
|
|
1451
1539
|
|
|
1452
1540
|
////////////
|
|
1453
|
-
|
|
1541
|
+
function calcSnap2(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y, allArea) {
|
|
1454
1542
|
var nx = x;
|
|
1455
1543
|
var ny = y;
|
|
1456
1544
|
var ndist = 20;
|
|
@@ -1594,7 +1682,7 @@ export function calcSnap2(allItemRect, allItemSnap, allLineRects, allLineSnap, a
|
|
|
1594
1682
|
return intersectRect(others.rect, curitem.rect);
|
|
1595
1683
|
});
|
|
1596
1684
|
intersects.forEach(function (rect) {
|
|
1597
|
-
if (isPointInArea(allArea, rect.itemInfo) || !allArea.length) if (rect.itemInfo.layoutpos.includes(BASE_CABINET_LAYOUTPOS)) {
|
|
1685
|
+
if (isPointInArea(allArea, rect.itemInfo) || !allArea.length) if (rect.itemInfo.layoutpos.includes(_constants.BASE_CABINET_LAYOUTPOS)) {
|
|
1598
1686
|
nx = rect.itemInfo.x;
|
|
1599
1687
|
ny = rect.itemInfo.y;
|
|
1600
1688
|
rotRad = rect.itemInfo.rotation * Math.PI / 180;
|
|
@@ -1621,7 +1709,7 @@ export function calcSnap2(allItemRect, allItemSnap, allLineRects, allLineSnap, a
|
|
|
1621
1709
|
//Check case.
|
|
1622
1710
|
//If item is 'blind base cabinet', it must be pulled from other 3".
|
|
1623
1711
|
if (allItemRect.cur && allItemRect.cur.itemInfo.sku_number.startsWith('BBC')) {
|
|
1624
|
-
var offset3inch = convert(3).from('in').to('cm');
|
|
1712
|
+
var offset3inch = (0, _convertUnitsLite.convert)(3).from('in').to('cm');
|
|
1625
1713
|
var tx = nx,
|
|
1626
1714
|
ty = ny;
|
|
1627
1715
|
if (allItemRect.cur && allItemRect.cur.itemInfo.sku_number.endsWith('-L')) {
|
|
@@ -1666,7 +1754,7 @@ export function calcSnap2(allItemRect, allItemSnap, allLineRects, allLineSnap, a
|
|
|
1666
1754
|
}
|
|
1667
1755
|
|
|
1668
1756
|
////////////
|
|
1669
|
-
|
|
1757
|
+
function calcSnap3(allItemRect, allItemSnap, allLineRects, allLineSnap, allRect, x, y) {
|
|
1670
1758
|
// let layer = scene.layers.get(layerID);
|
|
1671
1759
|
// let cx = allItemRect.cur.pos.x;
|
|
1672
1760
|
// let cy = allItemRect.cur.pos.y;
|
|
@@ -1781,10 +1869,10 @@ export function calcSnap3(allItemRect, allItemSnap, allLineRects, allLineSnap, a
|
|
|
1781
1869
|
rotRad: rotRad
|
|
1782
1870
|
};
|
|
1783
1871
|
}
|
|
1784
|
-
|
|
1872
|
+
function getAllCurSnap(allLineRects, x, y, curItemRect) {
|
|
1785
1873
|
if (!curItemRect) return;
|
|
1786
1874
|
var allCurSnap = [];
|
|
1787
|
-
var thick = LINE_THICKNESS / 2;
|
|
1875
|
+
var thick = _constants.LINE_THICKNESS / 2;
|
|
1788
1876
|
allLineRects.forEach(function (linerect) {
|
|
1789
1877
|
//allLineRects:left, right, top, bottom line
|
|
1790
1878
|
var p0 = clone_point(linerect.rect[2]); //point 2(x, y) inside of line
|
|
@@ -1819,15 +1907,15 @@ export function getAllCurSnap(allLineRects, x, y, curItemRect) {
|
|
|
1819
1907
|
});
|
|
1820
1908
|
return allCurSnap;
|
|
1821
1909
|
}
|
|
1822
|
-
|
|
1910
|
+
function clone_point(pt) {
|
|
1823
1911
|
return point(pt.x, pt.y);
|
|
1824
1912
|
}
|
|
1825
|
-
|
|
1913
|
+
function dotprod(v0, v1) {
|
|
1826
1914
|
return v0.x * v1.x + v0.y * v1.y;
|
|
1827
1915
|
}
|
|
1828
1916
|
|
|
1829
1917
|
//////////
|
|
1830
|
-
|
|
1918
|
+
function validInterSect(rect, val) {
|
|
1831
1919
|
var curitem = getCalcRectFromItem(val);
|
|
1832
1920
|
var datas = [];
|
|
1833
1921
|
rect.forEach(function (line) {
|
|
@@ -1857,7 +1945,7 @@ var lineRect = function lineRect(layer) {
|
|
|
1857
1945
|
});
|
|
1858
1946
|
return rect;
|
|
1859
1947
|
};
|
|
1860
|
-
|
|
1948
|
+
function getAllHoleRect(scene, val) {
|
|
1861
1949
|
var layerID = scene.selectedLayer;
|
|
1862
1950
|
var layer = scene.layers.get(layerID);
|
|
1863
1951
|
var selectedItem = layer.getIn(['items', layer.selected.items.get(0)]);
|
|
@@ -1901,7 +1989,7 @@ export function getAllHoleRect(scene, val) {
|
|
|
1901
1989
|
y: vertice1.y
|
|
1902
1990
|
};
|
|
1903
1991
|
var rotation = Math.atan2(point1.y - point0.y, point1.x - point0.x);
|
|
1904
|
-
var rectInfo = getCalcRectFromLine(point0.x, point0.y, point1.x, point1.y, LINE_THICKNESS, layer);
|
|
1992
|
+
var rectInfo = getCalcRectFromLine(point0.x, point0.y, point1.x, point1.y, _constants.LINE_THICKNESS, layer);
|
|
1905
1993
|
var vN = point(rectInfo.rect[0].x - rectInfo.rect[3].x, rectInfo.rect[0].y - rectInfo.rect[3].y);
|
|
1906
1994
|
var lenN = Math.sqrt(vN.x * vN.x + vN.y * vN.y);
|
|
1907
1995
|
vN.x /= lenN;
|
|
@@ -1923,7 +2011,7 @@ export function getAllHoleRect(scene, val) {
|
|
|
1923
2011
|
};
|
|
1924
2012
|
var hole_rect = getCalcRectFromItem(tval);
|
|
1925
2013
|
if (intersectRect(itemRect.rect, hole_rect.rect)) {
|
|
1926
|
-
if (tdepth > itemRect.size.depth && itemRect.layoutpos !== WALL_CABINET_LAYOUTPOS) {
|
|
2014
|
+
if (tdepth > itemRect.size.depth && itemRect.layoutpos !== _constants.WALL_CABINET_LAYOUTPOS) {
|
|
1927
2015
|
var dist = itemRect.size.height / 2 + theight / 2;
|
|
1928
2016
|
var snap = [];
|
|
1929
2017
|
var p0 = {
|
|
@@ -1956,7 +2044,7 @@ export function getAllHoleRect(scene, val) {
|
|
|
1956
2044
|
snap: null
|
|
1957
2045
|
};
|
|
1958
2046
|
}
|
|
1959
|
-
|
|
2047
|
+
function getHoleItems(layer) {
|
|
1960
2048
|
var holeItems = [];
|
|
1961
2049
|
layer.holes.map(function (hole) {
|
|
1962
2050
|
var width = hole.properties.getIn(['width', 'length']);
|
|
@@ -1970,18 +2058,18 @@ export function getHoleItems(layer) {
|
|
|
1970
2058
|
});
|
|
1971
2059
|
return holeItems;
|
|
1972
2060
|
}
|
|
1973
|
-
|
|
2061
|
+
function needSnap(curItem, othItem) {
|
|
1974
2062
|
var blSnap = false;
|
|
1975
2063
|
if (curItem == undefined || curItem == null) return false;
|
|
1976
2064
|
var altitude = curItem.selectedItem.properties.get('altitude');
|
|
1977
|
-
var heightFromFloor = convert(altitude.get('_length')).from(altitude.get('_unit')).to('in');
|
|
2065
|
+
var heightFromFloor = (0, _convertUnitsLite.convert)(altitude.get('_length')).from(altitude.get('_unit')).to('in');
|
|
1978
2066
|
var height = curItem.cat.info.sizeinfo.height;
|
|
1979
2067
|
var currentItem = {
|
|
1980
2068
|
heightFromFloor: heightFromFloor,
|
|
1981
2069
|
height: height
|
|
1982
2070
|
};
|
|
1983
2071
|
altitude = othItem.item.properties.get('altitude');
|
|
1984
|
-
heightFromFloor = convert(altitude.get('_length')).from(altitude.get('_unit')).to('in');
|
|
2072
|
+
heightFromFloor = (0, _convertUnitsLite.convert)(altitude.get('_length')).from(altitude.get('_unit')).to('in');
|
|
1985
2073
|
height = othItem.cat && othItem.cat.info.sizeinfo.height;
|
|
1986
2074
|
var otherItem = {
|
|
1987
2075
|
heightFromFloor: heightFromFloor,
|
|
@@ -1999,7 +2087,7 @@ export function needSnap(curItem, othItem) {
|
|
|
1999
2087
|
}
|
|
2000
2088
|
return blSnap;
|
|
2001
2089
|
}
|
|
2002
|
-
|
|
2090
|
+
function isFrontWall(v0, v1) {
|
|
2003
2091
|
var x1 = v0.x,
|
|
2004
2092
|
y1 = v0.y;
|
|
2005
2093
|
var x2 = v1.x,
|
|
@@ -2007,7 +2095,7 @@ export function isFrontWall(v0, v1) {
|
|
|
2007
2095
|
var alpha = angleBetweenTwoPoints(x1, y1, x2, y2);
|
|
2008
2096
|
return almostEqual(y1, y2) && x1 < x2 || -Math.PI / 2 < alpha && alpha < Math.PI / 2;
|
|
2009
2097
|
}
|
|
2010
|
-
|
|
2098
|
+
function isBackWall(v0, v1) {
|
|
2011
2099
|
var x1 = v0.x,
|
|
2012
2100
|
y1 = v0.y;
|
|
2013
2101
|
var x2 = v1.x,
|
|
@@ -2015,7 +2103,7 @@ export function isBackWall(v0, v1) {
|
|
|
2015
2103
|
var alpha = angleBetweenTwoPoints(x1, y1, x2, y2);
|
|
2016
2104
|
return almostEqual(y1, y2) && x1 > x2 || -Math.PI / 2 > alpha || alpha > Math.PI / 2;
|
|
2017
2105
|
}
|
|
2018
|
-
|
|
2106
|
+
function isLeftWall(v0, v1) {
|
|
2019
2107
|
var x1 = v0.x,
|
|
2020
2108
|
y1 = v0.y;
|
|
2021
2109
|
var x2 = v1.x,
|
|
@@ -2023,7 +2111,7 @@ export function isLeftWall(v0, v1) {
|
|
|
2023
2111
|
var alpha = angleBetweenTwoPoints(x1, y1, x2, y2);
|
|
2024
2112
|
return almostEqual(x1, x2) && y1 < y2 || Math.PI > alpha && alpha > 0;
|
|
2025
2113
|
}
|
|
2026
|
-
|
|
2114
|
+
function isRightWall(v0, v1) {
|
|
2027
2115
|
var x1 = v0.x,
|
|
2028
2116
|
y1 = v0.y;
|
|
2029
2117
|
var x2 = v1.x,
|
|
@@ -2042,7 +2130,7 @@ export function isRightWall(v0, v1) {
|
|
|
2042
2130
|
* OVERLAP_LINK: two lines are linked at the common point, so they can be merged to one line
|
|
2043
2131
|
* OVERLAP_INCLUDED: destLine includes srcLine
|
|
2044
2132
|
* OVERLAP_SOME: two lines are overlapped with some common range, then returns the trimmed segments of srcLine
|
|
2045
|
-
*
|
|
2133
|
+
*
|
|
2046
2134
|
* //////// test - start /////////////
|
|
2047
2135
|
const p1 = { x1: 1413.1313131313132, y1: 1044.949494949495 };
|
|
2048
2136
|
const p2 = { x1: 1476.2626262626263, y1: 1108.0808080808079 };
|
|
@@ -2056,7 +2144,7 @@ export function isRightWall(v0, v1) {
|
|
|
2056
2144
|
//////// test - end /////////////
|
|
2057
2145
|
|
|
2058
2146
|
*/
|
|
2059
|
-
|
|
2147
|
+
function relationshipOfTwoOverlappedLines(srcLine, destLine) {
|
|
2060
2148
|
// let res1 = relationshipOfTwoOverlappedLines1(srcLine, destLine);
|
|
2061
2149
|
var res2 = relationshipOfTwoOverlappedLines2(srcLine, destLine);
|
|
2062
2150
|
// if (res1.result !== 0 || res2.result !== 0) {
|
|
@@ -2068,7 +2156,7 @@ export function relationshipOfTwoOverlappedLines(srcLine, destLine) {
|
|
|
2068
2156
|
// }
|
|
2069
2157
|
return res2;
|
|
2070
2158
|
}
|
|
2071
|
-
|
|
2159
|
+
function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
|
|
2072
2160
|
var p1 = {
|
|
2073
2161
|
x: srcLine.x1,
|
|
2074
2162
|
y: srcLine.y1
|
|
@@ -2096,10 +2184,10 @@ export function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
|
|
|
2096
2184
|
var denom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);
|
|
2097
2185
|
var numA = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3);
|
|
2098
2186
|
var numB = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3);
|
|
2099
|
-
if (fAbs(denom) <= EPSILON) {
|
|
2100
|
-
if (fAbs(numA) <= EPSILON && fAbs(numB) <= EPSILON) {
|
|
2187
|
+
if ((0, _math.fAbs)(denom) <= _constants.EPSILON) {
|
|
2188
|
+
if ((0, _math.fAbs)(numA) <= _constants.EPSILON && (0, _math.fAbs)(numB) <= _constants.EPSILON) {
|
|
2101
2189
|
var comparator = function comparator(pa, pb) {
|
|
2102
|
-
return fAbs(pa.x - pb.x) <= EPSILON ? pa.y - pb.y : pa.x - pb.x;
|
|
2190
|
+
return (0, _math.fAbs)(pa.x - pb.x) <= _constants.EPSILON ? pa.y - pb.y : pa.x - pb.x;
|
|
2103
2191
|
};
|
|
2104
2192
|
var line0 = [p1, p2].sort(comparator);
|
|
2105
2193
|
var line1 = [p3, p4].sort(comparator);
|
|
@@ -2108,7 +2196,7 @@ export function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
|
|
|
2108
2196
|
var _sort3 = [line0, line1].sort(function (lineA, lineB) {
|
|
2109
2197
|
return comparator(lineA[0], lineB[0]);
|
|
2110
2198
|
}),
|
|
2111
|
-
_sort4 =
|
|
2199
|
+
_sort4 = (0, _slicedToArray2["default"])(_sort3, 2),
|
|
2112
2200
|
lineSX = _sort4[0],
|
|
2113
2201
|
lineDX = _sort4[1];
|
|
2114
2202
|
var isReversedSrcLineIdx = false;
|
|
@@ -2116,17 +2204,17 @@ export function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
|
|
|
2116
2204
|
var compare0 = comparator(lineSX[0], lineDX[0]);
|
|
2117
2205
|
var compare1 = comparator(lineSX[1], lineDX[0]);
|
|
2118
2206
|
var compare2 = comparator(lineSX[1], lineDX[1]);
|
|
2119
|
-
if (MathUtils.fAbs(compare0) < EPSILON && MathUtils.fAbs(compare2) < EPSILON) {
|
|
2207
|
+
if (_export.MathUtils.fAbs(compare0) < _constants.EPSILON && _export.MathUtils.fAbs(compare2) < _constants.EPSILON) {
|
|
2120
2208
|
return {
|
|
2121
|
-
result: OVERLAP_SAME
|
|
2209
|
+
result: _constants.OVERLAP_SAME
|
|
2122
2210
|
};
|
|
2123
|
-
} else if (MathUtils.fAbs(compare0) < EPSILON && compare2 < 0) {
|
|
2211
|
+
} else if (_export.MathUtils.fAbs(compare0) < _constants.EPSILON && compare2 < 0) {
|
|
2124
2212
|
// lineDX includes lineSX
|
|
2125
2213
|
if (!isReversedSrcLineIdx) {
|
|
2126
2214
|
// dest === lineDX : dest includes src
|
|
2127
2215
|
// return OVERLAP_INCLUDED; // lineSX[1] - lineDX[1]
|
|
2128
2216
|
return {
|
|
2129
|
-
result: OVERLAP_INCLUDED
|
|
2217
|
+
result: _constants.OVERLAP_INCLUDED
|
|
2130
2218
|
};
|
|
2131
2219
|
}
|
|
2132
2220
|
// else {
|
|
@@ -2143,10 +2231,10 @@ export function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
|
|
|
2143
2231
|
// };
|
|
2144
2232
|
// }
|
|
2145
2233
|
}
|
|
2146
|
-
if (MathUtils.fAbs(compare1) < EPSILON) {
|
|
2234
|
+
if (_export.MathUtils.fAbs(compare1) < _constants.EPSILON) {
|
|
2147
2235
|
// return OVERLAP_LINK; // lineSX[1]
|
|
2148
2236
|
return {
|
|
2149
|
-
result: OVERLAP_LINK,
|
|
2237
|
+
result: _constants.OVERLAP_LINK,
|
|
2150
2238
|
linkedLine: {
|
|
2151
2239
|
x1: isReversedSrcLineDirection ? lineDX[1].x : lineSX[0].x,
|
|
2152
2240
|
y1: isReversedSrcLineDirection ? lineDX[1].y : lineSX[0].y,
|
|
@@ -2156,16 +2244,16 @@ export function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
|
|
|
2156
2244
|
};
|
|
2157
2245
|
} else if (compare1 < 0) {
|
|
2158
2246
|
return {
|
|
2159
|
-
result: OVERLAP_NONE
|
|
2247
|
+
result: _constants.OVERLAP_NONE
|
|
2160
2248
|
};
|
|
2161
2249
|
} else {
|
|
2162
|
-
if (MathUtils.fAbs(compare2) < EPSILON || compare2 > 0) {
|
|
2250
|
+
if (_export.MathUtils.fAbs(compare2) < _constants.EPSILON || compare2 > 0) {
|
|
2163
2251
|
// lineSX includes lineDX
|
|
2164
2252
|
if (isReversedSrcLineIdx) {
|
|
2165
2253
|
// dest === lineSX : dest includes src
|
|
2166
2254
|
// return OVERLAP_INCLUDED; // lineDX[0] - lineDX[1]
|
|
2167
2255
|
return {
|
|
2168
|
-
result: OVERLAP_INCLUDED
|
|
2256
|
+
result: _constants.OVERLAP_INCLUDED
|
|
2169
2257
|
};
|
|
2170
2258
|
} else {
|
|
2171
2259
|
// dest === lineDX : src includes dest
|
|
@@ -2184,7 +2272,7 @@ export function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
|
|
|
2184
2272
|
y2: isReversedSrcLineDirection ? lineDX[1].y : lineSX[1].y
|
|
2185
2273
|
});
|
|
2186
2274
|
return {
|
|
2187
|
-
result: OVERLAP_SOME,
|
|
2275
|
+
result: _constants.OVERLAP_SOME,
|
|
2188
2276
|
trimmedSegs: trimmedSegs
|
|
2189
2277
|
};
|
|
2190
2278
|
}
|
|
@@ -2205,7 +2293,7 @@ export function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
|
|
|
2205
2293
|
y2: isReversedSrcLineDirection ? lineSX[1].y : lineDX[1].y
|
|
2206
2294
|
});
|
|
2207
2295
|
return {
|
|
2208
|
-
result: OVERLAP_SOME,
|
|
2296
|
+
result: _constants.OVERLAP_SOME,
|
|
2209
2297
|
trimmedSegs: _trimmedSegs
|
|
2210
2298
|
};
|
|
2211
2299
|
}
|
|
@@ -2213,46 +2301,46 @@ export function relationshipOfTwoOverlappedLines2(srcLine, destLine) {
|
|
|
2213
2301
|
}
|
|
2214
2302
|
}
|
|
2215
2303
|
return {
|
|
2216
|
-
result: OVERLAP_NONE
|
|
2304
|
+
result: _constants.OVERLAP_NONE
|
|
2217
2305
|
};
|
|
2218
2306
|
}
|
|
2219
|
-
|
|
2307
|
+
function relationshipOfTwoOverlappedLines1(srcLine, destLine) {
|
|
2220
2308
|
var INFINITY = 1000000;
|
|
2221
2309
|
var ZERO_DELTA = 0.01;
|
|
2222
2310
|
// geometric equation of srcLine
|
|
2223
2311
|
var dx1 = srcLine.x2 - srcLine.x1;
|
|
2224
|
-
dx1 = MathUtils.fAbs(dx1) < ZERO_DELTA ? 0 : dx1;
|
|
2312
|
+
dx1 = _export.MathUtils.fAbs(dx1) < ZERO_DELTA ? 0 : dx1;
|
|
2225
2313
|
var dy1 = srcLine.y2 - srcLine.y1;
|
|
2226
|
-
dy1 = MathUtils.fAbs(dy1) < ZERO_DELTA ? 0 : dy1;
|
|
2314
|
+
dy1 = _export.MathUtils.fAbs(dy1) < ZERO_DELTA ? 0 : dy1;
|
|
2227
2315
|
var a1 = dx1 === 0 ? INFINITY : dy1 / dx1;
|
|
2228
2316
|
var b1 = a1 === INFINITY ? srcLine.x1 : srcLine.y1 - a1 * srcLine.x1;
|
|
2229
2317
|
// geometric equation of destLine
|
|
2230
2318
|
var dx2 = destLine.x2 - destLine.x1;
|
|
2231
|
-
dx2 = MathUtils.fAbs(dx2) < ZERO_DELTA ? 0 : dx2;
|
|
2319
|
+
dx2 = _export.MathUtils.fAbs(dx2) < ZERO_DELTA ? 0 : dx2;
|
|
2232
2320
|
var dy2 = destLine.y2 - destLine.y1;
|
|
2233
|
-
dy2 = MathUtils.fAbs(dy2) < ZERO_DELTA ? 0 : dy2;
|
|
2321
|
+
dy2 = _export.MathUtils.fAbs(dy2) < ZERO_DELTA ? 0 : dy2;
|
|
2234
2322
|
var a2 = dx2 === 0 ? INFINITY : dy2 / dx2;
|
|
2235
2323
|
var b2 = a2 === INFINITY ? destLine.x1 : destLine.y1 - a2 * destLine.x1;
|
|
2236
|
-
if (MathUtils.fAbs(MathUtils.fAbs(a1) - MathUtils.fAbs(a2)) > ZERO_DELTA)
|
|
2324
|
+
if (_export.MathUtils.fAbs(_export.MathUtils.fAbs(a1) - _export.MathUtils.fAbs(a2)) > ZERO_DELTA)
|
|
2237
2325
|
// two lines are not parallel
|
|
2238
2326
|
return {
|
|
2239
|
-
result: OVERLAP_NONE
|
|
2327
|
+
result: _constants.OVERLAP_NONE
|
|
2240
2328
|
};
|
|
2241
|
-
if (MathUtils.fAbs(MathUtils.fAbs(b1) - MathUtils.fAbs(b2)) > ZERO_DELTA)
|
|
2329
|
+
if (_export.MathUtils.fAbs(_export.MathUtils.fAbs(b1) - _export.MathUtils.fAbs(b2)) > ZERO_DELTA)
|
|
2242
2330
|
// two lines are parallel but not overlap
|
|
2243
2331
|
return {
|
|
2244
|
-
result: OVERLAP_NONE
|
|
2332
|
+
result: _constants.OVERLAP_NONE
|
|
2245
2333
|
};
|
|
2246
2334
|
|
|
2247
2335
|
// parametric equation of destLine
|
|
2248
|
-
var sk1 = dx1 === 0 ? INFINITY : MathUtils.toFixedFloat((destLine.x1 - srcLine.x1) / dx1, 3);
|
|
2249
|
-
var sk2 = dy1 === 0 ? INFINITY : MathUtils.toFixedFloat((destLine.y1 - srcLine.y1) / dy1, 3);
|
|
2250
|
-
var ek1 = dx1 === 0 ? INFINITY : MathUtils.toFixedFloat((destLine.x2 - srcLine.x1) / dx1, 3);
|
|
2251
|
-
var ek2 = dy1 === 0 ? INFINITY : MathUtils.toFixedFloat((destLine.y2 - srcLine.y1) / dy1, 3);
|
|
2336
|
+
var sk1 = dx1 === 0 ? INFINITY : _export.MathUtils.toFixedFloat((destLine.x1 - srcLine.x1) / dx1, 3);
|
|
2337
|
+
var sk2 = dy1 === 0 ? INFINITY : _export.MathUtils.toFixedFloat((destLine.y1 - srcLine.y1) / dy1, 3);
|
|
2338
|
+
var ek1 = dx1 === 0 ? INFINITY : _export.MathUtils.toFixedFloat((destLine.x2 - srcLine.x1) / dx1, 3);
|
|
2339
|
+
var ek2 = dy1 === 0 ? INFINITY : _export.MathUtils.toFixedFloat((destLine.y2 - srcLine.y1) / dy1, 3);
|
|
2252
2340
|
if (sk1 !== INFINITY && sk2 !== INFINITY && ek1 !== INFINITY && ek2 !== INFINITY && (sk1 !== sk2 || ek1 !== ek2))
|
|
2253
2341
|
// destLine does not overlap with srcLine
|
|
2254
2342
|
return {
|
|
2255
|
-
result: OVERLAP_NONE
|
|
2343
|
+
result: _constants.OVERLAP_NONE
|
|
2256
2344
|
};
|
|
2257
2345
|
|
|
2258
2346
|
// parameter of destLine on the start and end points
|
|
@@ -2266,17 +2354,17 @@ export function relationshipOfTwoOverlappedLines1(srcLine, destLine) {
|
|
|
2266
2354
|
if (sk < 0 && ek < 0 || sk > 1 && ek > 1)
|
|
2267
2355
|
// not overlap
|
|
2268
2356
|
return {
|
|
2269
|
-
result: OVERLAP_NONE
|
|
2357
|
+
result: _constants.OVERLAP_NONE
|
|
2270
2358
|
};
|
|
2271
2359
|
if (sk === 0 && ek === 1 || sk === 1 && ek === 0)
|
|
2272
2360
|
// same lines
|
|
2273
2361
|
return {
|
|
2274
|
-
result: OVERLAP_SAME
|
|
2362
|
+
result: _constants.OVERLAP_SAME
|
|
2275
2363
|
};
|
|
2276
2364
|
if (sk <= 0 && ek >= 1 || sk >= 1 && ek <= 0)
|
|
2277
2365
|
// destLine includes srcLine
|
|
2278
2366
|
return {
|
|
2279
|
-
result: OVERLAP_INCLUDED
|
|
2367
|
+
result: _constants.OVERLAP_INCLUDED
|
|
2280
2368
|
};
|
|
2281
2369
|
if (sk === 0 && ek < 0 || sk === 1 && ek > 1 || ek === 0 && sk < 0 || ek === 1 && sk > 1) {
|
|
2282
2370
|
// linked with one common point
|
|
@@ -2319,14 +2407,14 @@ export function relationshipOfTwoOverlappedLines1(srcLine, destLine) {
|
|
|
2319
2407
|
};
|
|
2320
2408
|
}
|
|
2321
2409
|
return {
|
|
2322
|
-
result: OVERLAP_LINK,
|
|
2410
|
+
result: _constants.OVERLAP_LINK,
|
|
2323
2411
|
linkedLine: linkedLine
|
|
2324
2412
|
};
|
|
2325
2413
|
}
|
|
2326
2414
|
var trimmedSegment1 = null;
|
|
2327
2415
|
var trimmedSegment2 = null;
|
|
2328
2416
|
var ret = {
|
|
2329
|
-
result: OVERLAP_SOME,
|
|
2417
|
+
result: _constants.OVERLAP_SOME,
|
|
2330
2418
|
trimmedSegs: []
|
|
2331
2419
|
};
|
|
2332
2420
|
if (0 <= sk && sk <= 1 && 0 <= ek && ek <= 1) {
|
|
@@ -2412,7 +2500,7 @@ export function relationshipOfTwoOverlappedLines1(srcLine, destLine) {
|
|
|
2412
2500
|
* @param {Array} points //points of polygon
|
|
2413
2501
|
* @returns {Array} [centroid.x, centroid.y]
|
|
2414
2502
|
*/
|
|
2415
|
-
|
|
2503
|
+
function getCentroidOfPolygon(points) {
|
|
2416
2504
|
var center = points.reduce(function (x, y) {
|
|
2417
2505
|
return [x[0] + y[0] / points.length, x[1] + y[1] / points.length];
|
|
2418
2506
|
}, [0, 0]);
|