From 80c7f6c3ca2e2ca6c5aaaa431284475719fb467e Mon Sep 17 00:00:00 2001 From: xiefan <1789784602@qq.com> Date: Mon, 27 Apr 2020 16:39:48 +0800 Subject: [PATCH] init --- .eslintrc.js | 31 - README.md | 32 +- package-lock.json | 1067 +++++------------------- package.json | 17 +- src/App.vue | 69 +- src/Business/BlockConvert.ts | 21 + src/Business/BlockView.ts | 11 + src/Business/FileHelper.ts | 9 + src/Business/LayoutConfig.ts | 5 + src/Business/LayoutEngine.ts | 88 ++ src/Common/ArrayExt.ts | 185 ++++ src/Common/Sleep.ts | 7 + src/Nest/Common/Box2.ts | 160 ++++ src/Nest/Common/ClipperCpp.ts | 21 + src/Nest/Common/ConvexHull2D.ts | 8 + src/Nest/Common/Filer.ts | 30 + src/Nest/Common/Point.ts | 6 + src/Nest/Common/Random.ts | 9 + src/Nest/Common/Shuffle.ts | 8 + src/Nest/Common/Util.ts | 35 + src/Nest/Common/Vector2.ts | 287 +++++++ src/Nest/Core/Container.ts | 373 +++++++++ src/Nest/Core/DefaultBin.ts | 4 + src/Nest/Core/Individual.ts | 190 +++++ src/Nest/Core/NestCache.ts | 37 + src/Nest/Core/NestDatabase.ts | 54 ++ src/Nest/Core/OptimizeMachine.ts | 160 ++++ src/Nest/Core/OptimizeWorker.worker.ts | 27 + src/Nest/Core/Part.ts | 178 ++++ src/Nest/Core/PartState.ts | 35 + src/Nest/Core/Path.ts | 345 ++++++++ src/Nest/Core/PathGenerator.ts | 85 ++ src/Nest/Core/PlaceType.ts | 7 + src/assets/logo.png | Bin 6849 -> 0 bytes src/components/HelloWorld.vue | 132 --- src/components/SelectFile.vue | 36 + src/main.ts | 48 +- tests/unit/example.spec.ts | 12 - tsconfig.json | 22 +- vue.config.js | 44 + 40 files changed, 2776 insertions(+), 1119 deletions(-) delete mode 100644 .eslintrc.js create mode 100644 src/Business/BlockConvert.ts create mode 100644 src/Business/BlockView.ts create mode 100644 src/Business/FileHelper.ts create mode 100644 src/Business/LayoutConfig.ts create mode 100644 src/Business/LayoutEngine.ts create mode 100644 src/Common/ArrayExt.ts create mode 100644 src/Common/Sleep.ts create mode 100644 src/Nest/Common/Box2.ts create mode 100644 src/Nest/Common/ClipperCpp.ts create mode 100644 src/Nest/Common/ConvexHull2D.ts create mode 100644 src/Nest/Common/Filer.ts create mode 100644 src/Nest/Common/Point.ts create mode 100644 src/Nest/Common/Random.ts create mode 100644 src/Nest/Common/Shuffle.ts create mode 100644 src/Nest/Common/Util.ts create mode 100644 src/Nest/Common/Vector2.ts create mode 100644 src/Nest/Core/Container.ts create mode 100644 src/Nest/Core/DefaultBin.ts create mode 100644 src/Nest/Core/Individual.ts create mode 100644 src/Nest/Core/NestCache.ts create mode 100644 src/Nest/Core/NestDatabase.ts create mode 100644 src/Nest/Core/OptimizeMachine.ts create mode 100644 src/Nest/Core/OptimizeWorker.worker.ts create mode 100644 src/Nest/Core/Part.ts create mode 100644 src/Nest/Core/PartState.ts create mode 100644 src/Nest/Core/Path.ts create mode 100644 src/Nest/Core/PathGenerator.ts create mode 100644 src/Nest/Core/PlaceType.ts delete mode 100644 src/assets/logo.png delete mode 100644 src/components/HelloWorld.vue create mode 100644 src/components/SelectFile.vue delete mode 100644 tests/unit/example.spec.ts create mode 100644 vue.config.js diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 1489cc8..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1,31 +0,0 @@ -module.exports = { - root: true, - env: { - node: true - }, - extends: [ - "plugin:vue/essential", - "eslint:recommended", - "@vue/typescript/recommended", - "@vue/prettier", - "@vue/prettier/@typescript-eslint" - ], - parserOptions: { - ecmaVersion: 2020 - }, - rules: { - "no-console": process.env.NODE_ENV === "production" ? "warn" : "off", - "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off" - }, - overrides: [ - { - files: [ - "**/__tests__/*.{j,t}s?(x)", - "**/tests/unit/**/*.spec.{j,t}s?(x)" - ], - env: { - jest: true - } - } - ] -}; diff --git a/README.md b/README.md index 885b2eb..5662a2e 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,3 @@ -# cut-demo - -## Project setup -``` -npm install -``` - -### Compiles and hot-reloads for development -``` -npm run serve -``` - -### Compiles and minifies for production -``` -npm run build -``` - -### Run your unit tests -``` -npm run test:unit -``` - -### Lints and fixes files -``` -npm run lint -``` - -### Customize configuration -See [Configuration Reference](https://cli.vuejs.org/config/). +### 依赖 +- js-angusj-clipper +- monotone-convex-hull-2d \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index b013edd..2a3afed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1397,12 +1397,6 @@ "integrity": "sha1-HBJhu+qhCoBVu8XYq4S3sq/IRqA=", "dev": true }, - "@types/eslint-visitor-keys": { - "version": "1.0.0", - "resolved": "http://r.cnpmjs.org/@types/eslint-visitor-keys/download/@types/eslint-visitor-keys-1.0.0.tgz", - "integrity": "sha1-HuMNeVRMqE1o1LPNsK9PIFZj3S0=", - "dev": true - }, "@types/events": { "version": "3.0.0", "resolved": "http://r.cnpmjs.org/@types/events/download/@types/events-3.0.0.tgz", @@ -1454,12 +1448,6 @@ "jest-diff": "^24.3.0" } }, - "@types/json-schema": { - "version": "7.0.4", - "resolved": "http://r.cnpmjs.org/@types/json-schema/download/@types/json-schema-7.0.4.tgz", - "integrity": "sha1-OP1z3f2bVaux4bLtV4y1W9e30zk=", - "dev": true - }, "@types/minimatch": { "version": "3.0.3", "resolved": "http://r.cnpmjs.org/@types/minimatch/download/@types/minimatch-3.0.3.tgz", @@ -1523,97 +1511,6 @@ "integrity": "sha1-yz+fdBhp4gzOMw/765JxWQSDiC0=", "dev": true }, - "@typescript-eslint/eslint-plugin": { - "version": "2.29.0", - "resolved": "http://r.cnpmjs.org/@typescript-eslint/eslint-plugin/download/@typescript-eslint/eslint-plugin-2.29.0.tgz", - "integrity": "sha1-ye+rdiTj3W0USg5Fd6VB0b1Cwqw=", - "dev": true, - "requires": { - "@typescript-eslint/experimental-utils": "2.29.0", - "functional-red-black-tree": "^1.0.1", - "regexpp": "^3.0.0", - "tsutils": "^3.17.1" - }, - "dependencies": { - "tsutils": { - "version": "3.17.1", - "resolved": "http://r.cnpmjs.org/tsutils/download/tsutils-3.17.1.tgz", - "integrity": "sha1-7XGZF/EcoN7lhicrKsSeAVot11k=", - "dev": true, - "requires": { - "tslib": "^1.8.1" - } - } - } - }, - "@typescript-eslint/experimental-utils": { - "version": "2.29.0", - "resolved": "http://r.cnpmjs.org/@typescript-eslint/experimental-utils/download/@typescript-eslint/experimental-utils-2.29.0.tgz", - "integrity": "sha1-PLgGDekmW6ExYlqWu/7DG6bUoP4=", - "dev": true, - "requires": { - "@types/json-schema": "^7.0.3", - "@typescript-eslint/typescript-estree": "2.29.0", - "eslint-scope": "^5.0.0", - "eslint-utils": "^2.0.0" - }, - "dependencies": { - "eslint-scope": { - "version": "5.0.0", - "resolved": "http://r.cnpmjs.org/eslint-scope/download/eslint-scope-5.0.0.tgz", - "integrity": "sha1-6HyIh8c+jR7ITxylkWRcNYv8j7k=", - "dev": true, - "requires": { - "esrecurse": "^4.1.0", - "estraverse": "^4.1.1" - } - } - } - }, - "@typescript-eslint/parser": { - "version": "2.29.0", - "resolved": "http://r.cnpmjs.org/@typescript-eslint/parser/download/@typescript-eslint/parser-2.29.0.tgz", - "integrity": "sha1-bjxOIe1jk9wFudi0fwt+cx7yHJw=", - "dev": true, - "requires": { - "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/experimental-utils": "2.29.0", - "@typescript-eslint/typescript-estree": "2.29.0", - "eslint-visitor-keys": "^1.1.0" - } - }, - "@typescript-eslint/typescript-estree": { - "version": "2.29.0", - "resolved": "http://r.cnpmjs.org/@typescript-eslint/typescript-estree/download/@typescript-eslint/typescript-estree-2.29.0.tgz", - "integrity": "sha1-G+ZhK7Avw3rJ9GZSHBRZpHROjTo=", - "dev": true, - "requires": { - "debug": "^4.1.1", - "eslint-visitor-keys": "^1.1.0", - "glob": "^7.1.6", - "is-glob": "^4.0.1", - "lodash": "^4.17.15", - "semver": "^6.3.0", - "tsutils": "^3.17.1" - }, - "dependencies": { - "semver": { - "version": "6.3.0", - "resolved": "http://r.cnpmjs.org/semver/download/semver-6.3.0.tgz", - "integrity": "sha1-7gpkyK9ejO6mdoexM3YeG+y9HT0=", - "dev": true - }, - "tsutils": { - "version": "3.17.1", - "resolved": "http://r.cnpmjs.org/tsutils/download/tsutils-3.17.1.tgz", - "integrity": "sha1-7XGZF/EcoN7lhicrKsSeAVot11k=", - "dev": true, - "requires": { - "tslib": "^1.8.1" - } - } - } - }, "@vue/babel-helper-vue-jsx-merge-props": { "version": "1.0.0", "resolved": "http://r.cnpmjs.org/@vue/babel-helper-vue-jsx-merge-props/download/@vue/babel-helper-vue-jsx-merge-props-1.0.0.tgz", @@ -1734,20 +1631,6 @@ "webpack": "^4.0.0" } }, - "@vue/cli-plugin-eslint": { - "version": "4.3.1", - "resolved": "http://r.cnpmjs.org/@vue/cli-plugin-eslint/download/@vue/cli-plugin-eslint-4.3.1.tgz", - "integrity": "sha1-L14JvX0djElBNLbHGvK3eZONKJo=", - "dev": true, - "requires": { - "@vue/cli-shared-utils": "^4.3.1", - "eslint-loader": "^2.2.1", - "globby": "^9.2.0", - "inquirer": "^7.1.0", - "webpack": "^4.0.0", - "yorkie": "^2.0.0" - } - }, "@vue/cli-plugin-router": { "version": "4.3.1", "resolved": "http://r.cnpmjs.org/@vue/cli-plugin-router/download/@vue/cli-plugin-router-4.3.1.tgz", @@ -2175,24 +2058,6 @@ } } }, - "@vue/eslint-config-prettier": { - "version": "6.0.0", - "resolved": "http://r.cnpmjs.org/@vue/eslint-config-prettier/download/@vue/eslint-config-prettier-6.0.0.tgz", - "integrity": "sha1-rVkSswj0rkaEWOAqKwXbC50kZwA=", - "dev": true, - "requires": { - "eslint-config-prettier": "^6.0.0" - } - }, - "@vue/eslint-config-typescript": { - "version": "5.0.2", - "resolved": "http://r.cnpmjs.org/@vue/eslint-config-typescript/download/@vue/eslint-config-typescript-5.0.2.tgz", - "integrity": "sha1-wvMyjnDVXRCuuCbyCUBTl5YFSMc=", - "dev": true, - "requires": { - "vue-eslint-parser": "^7.0.0" - } - }, "@vue/preload-webpack-plugin": { "version": "1.1.1", "resolved": "http://r.cnpmjs.org/@vue/preload-webpack-plugin/download/@vue/preload-webpack-plugin-1.1.1.tgz", @@ -2441,12 +2306,6 @@ "acorn-walk": "^6.0.1" } }, - "acorn-jsx": { - "version": "5.2.0", - "resolved": "http://r.cnpmjs.org/acorn-jsx/download/acorn-jsx-5.2.0.tgz", - "integrity": "sha1-TGYGkXPW/daO2FI5/CViJhgrLr4=", - "dev": true - }, "acorn-walk": { "version": "6.2.0", "resolved": "http://r.cnpmjs.org/acorn-walk/download/acorn-walk-6.2.0.tgz", @@ -2473,7 +2332,6 @@ "version": "6.12.2", "resolved": "http://r.cnpmjs.org/ajv/download/ajv-6.12.2.tgz", "integrity": "sha1-xinF7O0XuvMUQ3kY0tqIyZ1ZWM0=", - "dev": true, "requires": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", @@ -2490,8 +2348,7 @@ "ajv-keywords": { "version": "3.4.1", "resolved": "http://r.cnpmjs.org/ajv-keywords/download/ajv-keywords-3.4.1.tgz", - "integrity": "sha1-75FuJxxkrBIXH9g4TqrmsjRYVNo=", - "dev": true + "integrity": "sha1-75FuJxxkrBIXH9g4TqrmsjRYVNo=" }, "alphanum-sort": { "version": "1.0.2", @@ -2728,6 +2585,14 @@ "integrity": "sha1-3TeelPDbgxCwgpH51kwyCXZmF/0=", "dev": true }, + "async-validator": { + "version": "1.8.5", + "resolved": "http://r.cnpmjs.org/async-validator/download/async-validator-1.8.5.tgz", + "integrity": "sha1-3D4I7B/Q3dtn5ghC8CwM0c7G1/A=", + "requires": { + "babel-runtime": "6.x" + } + }, "asynckit": { "version": "0.4.0", "resolved": "http://r.cnpmjs.org/asynckit/download/asynckit-0.4.0.tgz", @@ -2832,6 +2697,11 @@ "integrity": "sha1-laSS3dkPm06aSh2hTrM1uHtjTs4=", "dev": true }, + "babel-helper-vue-jsx-merge-props": { + "version": "2.0.3", + "resolved": "http://r.cnpmjs.org/babel-helper-vue-jsx-merge-props/download/babel-helper-vue-jsx-merge-props-2.0.3.tgz", + "integrity": "sha1-Iq69OzOQIyjlEyk6jkmSs4T58bY=" + }, "babel-jest": { "version": "24.9.0", "resolved": "http://r.cnpmjs.org/babel-jest/download/babel-jest-24.9.0.tgz", @@ -2980,7 +2850,6 @@ "version": "6.26.0", "resolved": "http://r.cnpmjs.org/babel-runtime/download/babel-runtime-6.26.0.tgz", "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", - "dev": true, "requires": { "core-js": "^2.4.0", "regenerator-runtime": "^0.11.0" @@ -2989,14 +2858,12 @@ "core-js": { "version": "2.6.11", "resolved": "http://r.cnpmjs.org/core-js/download/core-js-2.6.11.tgz", - "integrity": "sha1-OIMUafmSK97Y7iHJ3EaYXgOZMIw=", - "dev": true + "integrity": "sha1-OIMUafmSK97Y7iHJ3EaYXgOZMIw=" }, "regenerator-runtime": { "version": "0.11.1", "resolved": "http://r.cnpmjs.org/regenerator-runtime/download/regenerator-runtime-0.11.1.tgz", - "integrity": "sha1-vgWtf5v30i4Fb5cmzuUBf78Z4uk=", - "dev": true + "integrity": "sha1-vgWtf5v30i4Fb5cmzuUBf78Z4uk=" } } }, @@ -3176,8 +3043,7 @@ "big.js": { "version": "5.2.2", "resolved": "http://r.cnpmjs.org/big.js/download/big.js-5.2.2.tgz", - "integrity": "sha1-ZfCvOC9Xi83HQr2cKB6cstd2gyg=", - "dev": true + "integrity": "sha1-ZfCvOC9Xi83HQr2cKB6cstd2gyg=" }, "binary-extensions": { "version": "1.13.1", @@ -3234,6 +3100,15 @@ "ms": "2.0.0" } }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "http://r.cnpmjs.org/iconv-lite/download/iconv-lite-0.4.24.tgz", + "integrity": "sha1-ICK0sl+93CHS9SSXSkdKr+czkIs=", + "dev": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, "ms": { "version": "2.0.0", "resolved": "http://r.cnpmjs.org/ms/download/ms-2.0.0.tgz", @@ -3742,12 +3617,6 @@ "supports-color": "^5.3.0" } }, - "chardet": { - "version": "0.7.0", - "resolved": "http://r.cnpmjs.org/chardet/download/chardet-0.7.0.tgz", - "integrity": "sha1-kAlISfCTfy7twkJdDSip5fDLrZ4=", - "dev": true - }, "check-types": { "version": "8.0.3", "resolved": "http://r.cnpmjs.org/check-types/download/check-types-8.0.3.tgz", @@ -4038,12 +3907,6 @@ "integrity": "sha1-BjIjmktapMlYYQFCw0u3plH8jfU=", "dev": true }, - "cli-width": { - "version": "2.2.1", - "resolved": "http://r.cnpmjs.org/cli-width/download/cli-width-2.2.1.tgz", - "integrity": "sha1-sEM9C06chH7xiGik7xb9X8gnHEg=", - "dev": true - }, "clipboardy": { "version": "2.3.0", "resolved": "http://r.cnpmjs.org/clipboardy/download/clipboardy-2.3.0.tgz", @@ -4515,8 +4378,7 @@ "core-util-is": { "version": "1.0.2", "resolved": "http://r.cnpmjs.org/core-util-is/download/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, "cosmiconfig": { "version": "5.2.1", @@ -5256,15 +5118,6 @@ "buffer-indexof": "^1.0.0" } }, - "doctrine": { - "version": "3.0.0", - "resolved": "http://r.cnpmjs.org/doctrine/download/doctrine-3.0.0.tgz", - "integrity": "sha1-rd6+rXKmV023g2OdyHoSF3OXOWE=", - "dev": true, - "requires": { - "esutils": "^2.0.2" - } - }, "dom-converter": { "version": "0.2.0", "resolved": "http://r.cnpmjs.org/dom-converter/download/dom-converter-0.2.0.tgz", @@ -5441,6 +5294,26 @@ "integrity": "sha1-hAAhGR9Ga4A6hz4VQRNiDJ9TzsY=", "dev": true }, + "element-ui": { + "version": "2.13.1", + "resolved": "http://r.cnpmjs.org/element-ui/download/element-ui-2.13.1.tgz", + "integrity": "sha1-DLGkXPJ6phxgHe++GSdArFy533w=", + "requires": { + "async-validator": "~1.8.1", + "babel-helper-vue-jsx-merge-props": "^2.0.0", + "deepmerge": "^1.2.0", + "normalize-wheel": "^1.0.1", + "resize-observer-polyfill": "^1.5.0", + "throttle-debounce": "^1.0.1" + }, + "dependencies": { + "deepmerge": { + "version": "1.5.2", + "resolved": "http://r.cnpmjs.org/deepmerge/download/deepmerge-1.5.2.tgz", + "integrity": "sha1-EEmdhohEza1P7ghC34x/bwyVp1M=" + } + } + }, "elliptic": { "version": "6.5.2", "resolved": "http://r.cnpmjs.org/elliptic/download/elliptic-6.5.2.tgz", @@ -5465,8 +5338,7 @@ "emojis-list": { "version": "3.0.0", "resolved": "http://r.cnpmjs.org/emojis-list/download/emojis-list-3.0.0.tgz", - "integrity": "sha1-VXBmIEatKeLpFucariYKvf9Pang=", - "dev": true + "integrity": "sha1-VXBmIEatKeLpFucariYKvf9Pang=" }, "encodeurl": { "version": "1.0.2", @@ -5603,181 +5475,6 @@ } } }, - "eslint": { - "version": "6.8.0", - "resolved": "http://r.cnpmjs.org/eslint/download/eslint-6.8.0.tgz", - "integrity": "sha1-YiYtZylzn5J1cjgkMC+yJ8jJP/s=", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "ajv": "^6.10.0", - "chalk": "^2.1.0", - "cross-spawn": "^6.0.5", - "debug": "^4.0.1", - "doctrine": "^3.0.0", - "eslint-scope": "^5.0.0", - "eslint-utils": "^1.4.3", - "eslint-visitor-keys": "^1.1.0", - "espree": "^6.1.2", - "esquery": "^1.0.1", - "esutils": "^2.0.2", - "file-entry-cache": "^5.0.1", - "functional-red-black-tree": "^1.0.1", - "glob-parent": "^5.0.0", - "globals": "^12.1.0", - "ignore": "^4.0.6", - "import-fresh": "^3.0.0", - "imurmurhash": "^0.1.4", - "inquirer": "^7.0.0", - "is-glob": "^4.0.0", - "js-yaml": "^3.13.1", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.3.0", - "lodash": "^4.17.14", - "minimatch": "^3.0.4", - "mkdirp": "^0.5.1", - "natural-compare": "^1.4.0", - "optionator": "^0.8.3", - "progress": "^2.0.0", - "regexpp": "^2.0.1", - "semver": "^6.1.2", - "strip-ansi": "^5.2.0", - "strip-json-comments": "^3.0.1", - "table": "^5.2.3", - "text-table": "^0.2.0", - "v8-compile-cache": "^2.0.3" - }, - "dependencies": { - "eslint-scope": { - "version": "5.0.0", - "resolved": "http://r.cnpmjs.org/eslint-scope/download/eslint-scope-5.0.0.tgz", - "integrity": "sha1-6HyIh8c+jR7ITxylkWRcNYv8j7k=", - "dev": true, - "requires": { - "esrecurse": "^4.1.0", - "estraverse": "^4.1.1" - } - }, - "eslint-utils": { - "version": "1.4.3", - "resolved": "http://r.cnpmjs.org/eslint-utils/download/eslint-utils-1.4.3.tgz", - "integrity": "sha1-dP7HxU0Hdrb2fgJRBAtYBlZOmB8=", - "dev": true, - "requires": { - "eslint-visitor-keys": "^1.1.0" - } - }, - "glob-parent": { - "version": "5.1.1", - "resolved": "http://r.cnpmjs.org/glob-parent/download/glob-parent-5.1.1.tgz", - "integrity": "sha1-tsHvQXxOVmPqSY8cRa+saRa7wik=", - "dev": true, - "requires": { - "is-glob": "^4.0.1" - } - }, - "globals": { - "version": "12.4.0", - "resolved": "http://r.cnpmjs.org/globals/download/globals-12.4.0.tgz", - "integrity": "sha1-oYgTV2pBsAokqX5/gVkYwuGZJfg=", - "dev": true, - "requires": { - "type-fest": "^0.8.1" - } - }, - "import-fresh": { - "version": "3.2.1", - "resolved": "http://r.cnpmjs.org/import-fresh/download/import-fresh-3.2.1.tgz", - "integrity": "sha1-Yz/2GFBueTr1rJG/SLcmd+FcvmY=", - "dev": true, - "requires": { - "parent-module": "^1.0.0", - "resolve-from": "^4.0.0" - } - }, - "regexpp": { - "version": "2.0.1", - "resolved": "http://r.cnpmjs.org/regexpp/download/regexpp-2.0.1.tgz", - "integrity": "sha1-jRnTHPYySCtYkEn4KB+T28uk0H8=", - "dev": true - }, - "resolve-from": { - "version": "4.0.0", - "resolved": "http://r.cnpmjs.org/resolve-from/download/resolve-from-4.0.0.tgz", - "integrity": "sha1-SrzYUq0y3Xuqv+m0DgCjbbXzkuY=", - "dev": true - }, - "semver": { - "version": "6.3.0", - "resolved": "http://r.cnpmjs.org/semver/download/semver-6.3.0.tgz", - "integrity": "sha1-7gpkyK9ejO6mdoexM3YeG+y9HT0=", - "dev": true - }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "http://r.cnpmjs.org/strip-ansi/download/strip-ansi-5.2.0.tgz", - "integrity": "sha1-jJpTb+tq/JYr36WxBKUJHBrZwK4=", - "dev": true, - "requires": { - "ansi-regex": "^4.1.0" - } - }, - "strip-json-comments": { - "version": "3.1.0", - "resolved": "http://r.cnpmjs.org/strip-json-comments/download/strip-json-comments-3.1.0.tgz", - "integrity": "sha1-djjTFCISns9EV0QACfugP5+awYA=", - "dev": true - }, - "type-fest": { - "version": "0.8.1", - "resolved": "http://r.cnpmjs.org/type-fest/download/type-fest-0.8.1.tgz", - "integrity": "sha1-CeJJ696FHTseSNJ8EFREZn8XuD0=", - "dev": true - } - } - }, - "eslint-config-prettier": { - "version": "6.11.0", - "resolved": "http://r.cnpmjs.org/eslint-config-prettier/download/eslint-config-prettier-6.11.0.tgz", - "integrity": "sha1-9tIjjBKQ0ByFmotcH301KgsNqLE=", - "dev": true, - "requires": { - "get-stdin": "^6.0.0" - } - }, - "eslint-loader": { - "version": "2.2.1", - "resolved": "http://r.cnpmjs.org/eslint-loader/download/eslint-loader-2.2.1.tgz", - "integrity": "sha1-KLnBLaVAV68IReKmEScBova/gzc=", - "dev": true, - "requires": { - "loader-fs-cache": "^1.0.0", - "loader-utils": "^1.0.2", - "object-assign": "^4.0.1", - "object-hash": "^1.1.4", - "rimraf": "^2.6.1" - } - }, - "eslint-plugin-prettier": { - "version": "3.1.3", - "resolved": "http://r.cnpmjs.org/eslint-plugin-prettier/download/eslint-plugin-prettier-3.1.3.tgz", - "integrity": "sha1-rhFqD8DlmP2uSHQ6RDCQPeW05so=", - "dev": true, - "requires": { - "prettier-linter-helpers": "^1.0.0" - } - }, - "eslint-plugin-vue": { - "version": "6.2.2", - "resolved": "http://r.cnpmjs.org/eslint-plugin-vue/download/eslint-plugin-vue-6.2.2.tgz", - "integrity": "sha1-J/7NmjokeJsPER7N1UCp5WGY4P4=", - "dev": true, - "requires": { - "natural-compare": "^1.4.0", - "semver": "^5.6.0", - "vue-eslint-parser": "^7.0.0" - } - }, "eslint-scope": { "version": "4.0.3", "resolved": "http://r.cnpmjs.org/eslint-scope/download/eslint-scope-4.0.3.tgz", @@ -5788,63 +5485,12 @@ "estraverse": "^4.1.1" } }, - "eslint-utils": { - "version": "2.0.0", - "resolved": "http://r.cnpmjs.org/eslint-utils/download/eslint-utils-2.0.0.tgz", - "integrity": "sha1-e+HMcPJ6cqds0UqmmLyr7WiQ4c0=", - "dev": true, - "requires": { - "eslint-visitor-keys": "^1.1.0" - } - }, - "eslint-visitor-keys": { - "version": "1.1.0", - "resolved": "http://r.cnpmjs.org/eslint-visitor-keys/download/eslint-visitor-keys-1.1.0.tgz", - "integrity": "sha1-4qgs6oT/JGrW+1f5veW0ZiFFnsI=", - "dev": true - }, - "espree": { - "version": "6.2.1", - "resolved": "http://r.cnpmjs.org/espree/download/espree-6.2.1.tgz", - "integrity": "sha1-d/xy4f10SiBSwg84pbV1gy6Cc0o=", - "dev": true, - "requires": { - "acorn": "^7.1.1", - "acorn-jsx": "^5.2.0", - "eslint-visitor-keys": "^1.1.0" - }, - "dependencies": { - "acorn": { - "version": "7.1.1", - "resolved": "http://r.cnpmjs.org/acorn/download/acorn-7.1.1.tgz", - "integrity": "sha1-41Zo3gtALzWd5RXFSCoaufiaab8=", - "dev": true - } - } - }, "esprima": { "version": "4.0.1", "resolved": "http://r.cnpmjs.org/esprima/download/esprima-4.0.1.tgz", "integrity": "sha1-E7BM2z5sXRnfkatph6hpVhmwqnE=", "dev": true }, - "esquery": { - "version": "1.3.1", - "resolved": "http://r.cnpmjs.org/esquery/download/esquery-1.3.1.tgz", - "integrity": "sha1-t4tYKKqOIU4p+3TE1bdS4cAz2lc=", - "dev": true, - "requires": { - "estraverse": "^5.1.0" - }, - "dependencies": { - "estraverse": { - "version": "5.1.0", - "resolved": "http://r.cnpmjs.org/estraverse/download/estraverse-5.1.0.tgz", - "integrity": "sha1-N0MJ05/ZNa5QDnuS6Ka0xyDllkI=", - "dev": true - } - } - }, "esrecurse": { "version": "4.2.1", "resolved": "http://r.cnpmjs.org/esrecurse/download/esrecurse-4.2.1.tgz", @@ -6088,17 +5734,6 @@ } } }, - "external-editor": { - "version": "3.1.0", - "resolved": "http://r.cnpmjs.org/external-editor/download/external-editor-3.1.0.tgz", - "integrity": "sha1-ywP3QL764D6k0oPK7SdBqD8zVJU=", - "dev": true, - "requires": { - "chardet": "^0.7.0", - "iconv-lite": "^0.4.24", - "tmp": "^0.0.33" - } - }, "extglob": { "version": "2.0.4", "resolved": "http://r.cnpmjs.org/extglob/download/extglob-2.0.4.tgz", @@ -6182,14 +5817,7 @@ "fast-deep-equal": { "version": "3.1.1", "resolved": "http://r.cnpmjs.org/fast-deep-equal/download/fast-deep-equal-3.1.1.tgz", - "integrity": "sha1-VFFFB3xQFJHjOxXsQIwpQ3bpSuQ=", - "dev": true - }, - "fast-diff": { - "version": "1.2.0", - "resolved": "http://r.cnpmjs.org/fast-diff/download/fast-diff-1.2.0.tgz", - "integrity": "sha1-c+4RmC2Gyq95WYKNUZz+kn+sXwM=", - "dev": true + "integrity": "sha1-VFFFB3xQFJHjOxXsQIwpQ3bpSuQ=" }, "fast-glob": { "version": "2.2.7", @@ -6208,8 +5836,7 @@ "fast-json-stable-stringify": { "version": "2.1.0", "resolved": "http://r.cnpmjs.org/fast-json-stable-stringify/download/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha1-h0v2nG9ATCtdmcSBNBOZ/VWJJjM=", - "dev": true + "integrity": "sha1-h0v2nG9ATCtdmcSBNBOZ/VWJJjM=" }, "fast-levenshtein": { "version": "2.0.6", @@ -6241,24 +5868,6 @@ "integrity": "sha1-tO7oFIq7Adzx0aw0Nn1Z4S+mHW4=", "dev": true }, - "figures": { - "version": "3.2.0", - "resolved": "http://r.cnpmjs.org/figures/download/figures-3.2.0.tgz", - "integrity": "sha1-YlwYvSk8YE3EqN2y/r8MiDQXRq8=", - "dev": true, - "requires": { - "escape-string-regexp": "^1.0.5" - } - }, - "file-entry-cache": { - "version": "5.0.1", - "resolved": "http://r.cnpmjs.org/file-entry-cache/download/file-entry-cache-5.0.1.tgz", - "integrity": "sha1-yg9u+m3T1WEzP7FFFQZcL6/fQ5w=", - "dev": true, - "requires": { - "flat-cache": "^2.0.1" - } - }, "file-loader": { "version": "4.3.0", "resolved": "http://r.cnpmjs.org/file-loader/download/file-loader-4.3.0.tgz", @@ -6375,34 +5984,6 @@ "locate-path": "^2.0.0" } }, - "flat-cache": { - "version": "2.0.1", - "resolved": "http://r.cnpmjs.org/flat-cache/download/flat-cache-2.0.1.tgz", - "integrity": "sha1-XSltbwS9pEpGMKMBQTvbwuwIXsA=", - "dev": true, - "requires": { - "flatted": "^2.0.0", - "rimraf": "2.6.3", - "write": "1.0.3" - }, - "dependencies": { - "rimraf": { - "version": "2.6.3", - "resolved": "http://r.cnpmjs.org/rimraf/download/rimraf-2.6.3.tgz", - "integrity": "sha1-stEE/g2Psnz54KHNqCYt04M8bKs=", - "dev": true, - "requires": { - "glob": "^7.1.3" - } - } - } - }, - "flatted": { - "version": "2.0.2", - "resolved": "http://r.cnpmjs.org/flatted/download/flatted-2.0.2.tgz", - "integrity": "sha1-RXWyHivO50NKqb5mL0t7X5wrUTg=", - "dev": true - }, "flush-write-stream": { "version": "1.1.1", "resolved": "http://r.cnpmjs.org/flush-write-stream/download/flush-write-stream-1.1.1.tgz", @@ -7199,12 +6780,6 @@ "integrity": "sha1-pWiZ0+o8m6uHS7l3O3xe3pL0iV0=", "dev": true }, - "functional-red-black-tree": { - "version": "1.0.1", - "resolved": "http://r.cnpmjs.org/functional-red-black-tree/download/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", - "dev": true - }, "gensync": { "version": "1.0.0-beta.1", "resolved": "http://r.cnpmjs.org/gensync/download/gensync-1.0.0-beta.1.tgz", @@ -7217,12 +6792,6 @@ "integrity": "sha1-T5RBKoLbMvNuOwuXQfipf+sDH34=", "dev": true }, - "get-stdin": { - "version": "6.0.0", - "resolved": "http://r.cnpmjs.org/get-stdin/download/get-stdin-6.0.0.tgz", - "integrity": "sha1-ngm/cSs2CrkiXoEgSPcf3pyJZXs=", - "dev": true - }, "get-stream": { "version": "4.1.0", "resolved": "http://r.cnpmjs.org/get-stream/download/get-stream-4.1.0.tgz", @@ -7741,10 +7310,9 @@ "dev": true }, "iconv-lite": { - "version": "0.4.24", - "resolved": "http://r.cnpmjs.org/iconv-lite/download/iconv-lite-0.4.24.tgz", - "integrity": "sha1-ICK0sl+93CHS9SSXSkdKr+czkIs=", - "dev": true, + "version": "0.5.1", + "resolved": "http://r.cnpmjs.org/iconv-lite/download/iconv-lite-0.5.1.tgz", + "integrity": "sha1-skJdPHsY9yGfLKZj0QO925FxjWQ=", "requires": { "safer-buffer": ">= 2.1.2 < 3" } @@ -7776,6 +7344,11 @@ "integrity": "sha1-dQ49tYYgh7RzfrrIIH/9HvJ7Jfw=", "dev": true }, + "immediate": { + "version": "3.0.6", + "resolved": "http://r.cnpmjs.org/immediate/download/immediate-3.0.6.tgz", + "integrity": "sha1-nbHb0Pr43m++D13V5Wu2BigN5ps=" + }, "import-cwd": { "version": "2.1.0", "resolved": "http://r.cnpmjs.org/import-cwd/download/import-cwd-2.1.0.tgz", @@ -7851,8 +7424,7 @@ "inherits": { "version": "2.0.4", "resolved": "http://r.cnpmjs.org/inherits/download/inherits-2.0.4.tgz", - "integrity": "sha1-D6LGT5MpF8NDOg3tVTY6rjdBa3w=", - "dev": true + "integrity": "sha1-D6LGT5MpF8NDOg3tVTY6rjdBa3w=" }, "ini": { "version": "1.3.5", @@ -7860,113 +7432,6 @@ "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", "dev": true }, - "inquirer": { - "version": "7.1.0", - "resolved": "http://r.cnpmjs.org/inquirer/download/inquirer-7.1.0.tgz", - "integrity": "sha1-EpigGFmIPhfHJkuChwrhA0+S3Sk=", - "dev": true, - "requires": { - "ansi-escapes": "^4.2.1", - "chalk": "^3.0.0", - "cli-cursor": "^3.1.0", - "cli-width": "^2.0.0", - "external-editor": "^3.0.3", - "figures": "^3.0.0", - "lodash": "^4.17.15", - "mute-stream": "0.0.8", - "run-async": "^2.4.0", - "rxjs": "^6.5.3", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0", - "through": "^2.3.6" - }, - "dependencies": { - "ansi-styles": { - "version": "4.2.1", - "resolved": "http://r.cnpmjs.org/ansi-styles/download/ansi-styles-4.2.1.tgz", - "integrity": "sha1-kK51xCTQCNJiTFvynq0xd+v881k=", - "dev": true, - "requires": { - "@types/color-name": "^1.1.1", - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "3.0.0", - "resolved": "http://r.cnpmjs.org/chalk/download/chalk-3.0.0.tgz", - "integrity": "sha1-P3PCv1JlkfV0zEksUeJFY0n4ROQ=", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "cli-cursor": { - "version": "3.1.0", - "resolved": "http://r.cnpmjs.org/cli-cursor/download/cli-cursor-3.1.0.tgz", - "integrity": "sha1-JkMFp65JDR0Dvwybp8kl0XU68wc=", - "dev": true, - "requires": { - "restore-cursor": "^3.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "http://r.cnpmjs.org/color-convert/download/color-convert-2.0.1.tgz", - "integrity": "sha1-ctOmjVmMm9s68q0ehPIdiWq9TeM=", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "http://r.cnpmjs.org/color-name/download/color-name-1.1.4.tgz", - "integrity": "sha1-wqCah6y95pVD3m9j+jmVyCbFNqI=", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "http://r.cnpmjs.org/has-flag/download/has-flag-4.0.0.tgz", - "integrity": "sha1-lEdx/ZyByBJlxNaUGGDaBrtZR5s=", - "dev": true - }, - "mimic-fn": { - "version": "2.1.0", - "resolved": "http://r.cnpmjs.org/mimic-fn/download/mimic-fn-2.1.0.tgz", - "integrity": "sha1-ftLCzMyvhNP/y3pptXcR/CCDQBs=", - "dev": true - }, - "onetime": { - "version": "5.1.0", - "resolved": "http://r.cnpmjs.org/onetime/download/onetime-5.1.0.tgz", - "integrity": "sha1-//DzyRYX/mK7UBiWNumayKbfe+U=", - "dev": true, - "requires": { - "mimic-fn": "^2.1.0" - } - }, - "restore-cursor": { - "version": "3.1.0", - "resolved": "http://r.cnpmjs.org/restore-cursor/download/restore-cursor-3.1.0.tgz", - "integrity": "sha1-OfZ8VLOnpYzqUjbZXPADQjljH34=", - "dev": true, - "requires": { - "onetime": "^5.1.0", - "signal-exit": "^3.0.2" - } - }, - "supports-color": { - "version": "7.1.0", - "resolved": "http://r.cnpmjs.org/supports-color/download/supports-color-7.1.0.tgz", - "integrity": "sha1-aOMlkd9z4lrRxLSRCKLsUHliv9E=", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, "internal-ip": { "version": "4.3.0", "resolved": "http://r.cnpmjs.org/internal-ip/download/internal-ip-4.3.0.tgz", @@ -8253,12 +7718,6 @@ "isobject": "^3.0.1" } }, - "is-promise": { - "version": "2.2.2", - "resolved": "http://r.cnpmjs.org/is-promise/download/is-promise-2.2.2.tgz", - "integrity": "sha1-OauVnMv5p3TPB597QMeib3YxNfE=", - "dev": true - }, "is-regex": { "version": "1.0.5", "resolved": "http://r.cnpmjs.org/is-regex/download/is-regex-1.0.5.tgz", @@ -8325,8 +7784,7 @@ "isarray": { "version": "1.0.0", "resolved": "http://r.cnpmjs.org/isarray/download/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" }, "isexe": { "version": "2.0.0", @@ -9075,6 +8533,11 @@ } } }, + "js-angusj-clipper": { + "version": "1.0.4", + "resolved": "http://r.cnpmjs.org/js-angusj-clipper/download/js-angusj-clipper-1.0.4.tgz", + "integrity": "sha1-yewTiPDOMspe0MAY0nKP6Kvh/sc=" + }, "js-beautify": { "version": "1.11.0", "resolved": "http://r.cnpmjs.org/js-beautify/download/js-beautify-1.11.0.tgz", @@ -9196,14 +8659,7 @@ "json-schema-traverse": { "version": "0.4.1", "resolved": "http://r.cnpmjs.org/json-schema-traverse/download/json-schema-traverse-0.4.1.tgz", - "integrity": "sha1-afaofZUTq4u4/mO9sJecRI5oRmA=", - "dev": true - }, - "json-stable-stringify-without-jsonify": { - "version": "1.0.1", - "resolved": "http://r.cnpmjs.org/json-stable-stringify-without-jsonify/download/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", - "dev": true + "integrity": "sha1-afaofZUTq4u4/mO9sJecRI5oRmA=" }, "json-stringify-safe": { "version": "5.0.1", @@ -9247,6 +8703,17 @@ "verror": "1.10.0" } }, + "jszip": { + "version": "3.4.0", + "resolved": "http://r.cnpmjs.org/jszip/download/jszip-3.4.0.tgz", + "integrity": "sha1-GmlCH6Xwu5vCIqRryogYL7oHU1A=", + "requires": { + "lie": "~3.3.0", + "pako": "~1.0.2", + "readable-stream": "~2.3.6", + "set-immediate-shim": "~1.0.1" + } + }, "killable": { "version": "1.0.1", "resolved": "http://r.cnpmjs.org/killable/download/killable-1.0.1.tgz", @@ -9324,6 +8791,14 @@ "type-check": "~0.3.2" } }, + "lie": { + "version": "3.3.0", + "resolved": "http://r.cnpmjs.org/lie/download/lie-3.3.0.tgz", + "integrity": "sha1-3Pgt7lRfRgdNryAMfBxaCOD0D2o=", + "requires": { + "immediate": "~3.0.5" + } + }, "lines-and-columns": { "version": "1.1.6", "resolved": "http://r.cnpmjs.org/lines-and-columns/download/lines-and-columns-1.1.6.tgz", @@ -9360,57 +8835,6 @@ } } }, - "loader-fs-cache": { - "version": "1.0.3", - "resolved": "http://r.cnpmjs.org/loader-fs-cache/download/loader-fs-cache-1.0.3.tgz", - "integrity": "sha1-8IZXZG1gcHi+LwoDL4vWndbyd9k=", - "dev": true, - "requires": { - "find-cache-dir": "^0.1.1", - "mkdirp": "^0.5.1" - }, - "dependencies": { - "find-cache-dir": { - "version": "0.1.1", - "resolved": "http://r.cnpmjs.org/find-cache-dir/download/find-cache-dir-0.1.1.tgz", - "integrity": "sha1-yN765XyKUqinhPnjHFfHQumToLk=", - "dev": true, - "requires": { - "commondir": "^1.0.1", - "mkdirp": "^0.5.1", - "pkg-dir": "^1.0.0" - } - }, - "find-up": { - "version": "1.1.2", - "resolved": "http://r.cnpmjs.org/find-up/download/find-up-1.1.2.tgz", - "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", - "dev": true, - "requires": { - "path-exists": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, - "path-exists": { - "version": "2.1.0", - "resolved": "http://r.cnpmjs.org/path-exists/download/path-exists-2.1.0.tgz", - "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", - "dev": true, - "requires": { - "pinkie-promise": "^2.0.0" - } - }, - "pkg-dir": { - "version": "1.0.0", - "resolved": "http://r.cnpmjs.org/pkg-dir/download/pkg-dir-1.0.0.tgz", - "integrity": "sha1-ektQio1bstYp1EcFb/TpyTFM89Q=", - "dev": true, - "requires": { - "find-up": "^1.0.0" - } - } - } - }, "loader-runner": { "version": "2.4.0", "resolved": "http://r.cnpmjs.org/loader-runner/download/loader-runner-2.4.0.tgz", @@ -9421,7 +8845,6 @@ "version": "1.4.0", "resolved": "http://r.cnpmjs.org/loader-utils/download/loader-utils-1.4.0.tgz", "integrity": "sha1-xXm140yzSxp07cbB+za/o3HVphM=", - "dev": true, "requires": { "big.js": "^5.2.2", "emojis-list": "^3.0.0", @@ -9432,7 +8855,6 @@ "version": "1.0.1", "resolved": "http://r.cnpmjs.org/json5/download/json5-1.0.1.tgz", "integrity": "sha1-d5+wAYYE+oVOrL9iUhgNg1Q+Pb4=", - "dev": true, "requires": { "minimist": "^1.2.0" } @@ -9803,8 +9225,7 @@ "minimist": { "version": "1.2.5", "resolved": "http://r.cnpmjs.org/minimist/download/minimist-1.2.5.tgz", - "integrity": "sha1-Z9ZgFLZqaoqqDAg8X9WN9OTpdgI=", - "dev": true + "integrity": "sha1-Z9ZgFLZqaoqqDAg8X9WN9OTpdgI=" }, "minipass": { "version": "3.1.1", @@ -9898,6 +9319,14 @@ "minimist": "^1.2.5" } }, + "monotone-convex-hull-2d": { + "version": "1.0.1", + "resolved": "http://r.cnpmjs.org/monotone-convex-hull-2d/download/monotone-convex-hull-2d-1.0.1.tgz", + "integrity": "sha1-R/Xa6t88Sv03dkuqGqh4ekDu4Iw=", + "requires": { + "robust-orientation": "^1.1.3" + } + }, "move-concurrently": { "version": "1.0.1", "resolved": "http://r.cnpmjs.org/move-concurrently/download/move-concurrently-1.0.1.tgz", @@ -9934,12 +9363,6 @@ "integrity": "sha1-iZ8R2WhuXgXLkbNdXw5jt3PPyQE=", "dev": true }, - "mute-stream": { - "version": "0.0.8", - "resolved": "http://r.cnpmjs.org/mute-stream/download/mute-stream-0.0.8.tgz", - "integrity": "sha1-FjDEKyJR/4HiooPelqVJfqkuXg0=", - "dev": true - }, "mz": { "version": "2.7.0", "resolved": "http://r.cnpmjs.org/mz/download/mz-2.7.0.tgz", @@ -10155,6 +9578,11 @@ "integrity": "sha1-suHE3E98bVd0PfczpPWXjRhlBVk=", "dev": true }, + "normalize-wheel": { + "version": "1.0.1", + "resolved": "http://r.cnpmjs.org/normalize-wheel/download/normalize-wheel-1.0.1.tgz", + "integrity": "sha1-rsiGr/2wRQcNhWRH32Ls+GFG7EU=" + }, "npm-run-path": { "version": "2.0.2", "resolved": "http://r.cnpmjs.org/npm-run-path/download/npm-run-path-2.0.2.tgz", @@ -10234,12 +9662,6 @@ } } }, - "object-hash": { - "version": "1.3.1", - "resolved": "http://r.cnpmjs.org/object-hash/download/object-hash-1.3.1.tgz", - "integrity": "sha1-/eRSCYqVHLFF8Dm7fUVUSd3BJt8=", - "dev": true - }, "object-inspect": { "version": "1.7.0", "resolved": "http://r.cnpmjs.org/object-inspect/download/object-inspect-1.7.0.tgz", @@ -10542,8 +9964,7 @@ "pako": { "version": "1.0.11", "resolved": "http://r.cnpmjs.org/pako/download/pako-1.0.11.tgz", - "integrity": "sha1-bJWZ00DVTf05RjgCUqNXBaa5kr8=", - "dev": true + "integrity": "sha1-bJWZ00DVTf05RjgCUqNXBaa5kr8=" }, "parallel-transform": { "version": "1.2.0", @@ -10565,15 +9986,6 @@ "no-case": "^2.2.0" } }, - "parent-module": { - "version": "1.0.1", - "resolved": "http://r.cnpmjs.org/parent-module/download/parent-module-1.0.1.tgz", - "integrity": "sha1-aR0nCeeMefrjoVZiJFLQB2LKqqI=", - "dev": true, - "requires": { - "callsites": "^3.0.0" - } - }, "parse-asn1": { "version": "5.1.5", "resolved": "http://r.cnpmjs.org/parse-asn1/download/parse-asn1-5.1.5.tgz", @@ -11463,15 +10875,6 @@ "integrity": "sha1-99f1/4qc2HKnvkyhQglZVqYHl8s=", "dev": true }, - "prettier-linter-helpers": { - "version": "1.0.0", - "resolved": "http://r.cnpmjs.org/prettier-linter-helpers/download/prettier-linter-helpers-1.0.0.tgz", - "integrity": "sha1-0j1B/hN1ZG3i0BBNNFSjAIgCz3s=", - "dev": true, - "requires": { - "fast-diff": "^1.1.2" - } - }, "pretty": { "version": "2.0.0", "resolved": "http://r.cnpmjs.org/pretty/download/pretty-2.0.0.tgz", @@ -11531,14 +10934,7 @@ "process-nextick-args": { "version": "2.0.1", "resolved": "http://r.cnpmjs.org/process-nextick-args/download/process-nextick-args-2.0.1.tgz", - "integrity": "sha1-eCDZsWEgzFXKmud5JoCufbptf+I=", - "dev": true - }, - "progress": { - "version": "2.0.3", - "resolved": "http://r.cnpmjs.org/progress/download/progress-2.0.3.tgz", - "integrity": "sha1-foz42PW48jnBvGi+tOt4Vn1XLvg=", - "dev": true + "integrity": "sha1-eCDZsWEgzFXKmud5JoCufbptf+I=" }, "promise-inflight": { "version": "1.0.1", @@ -11640,8 +11036,7 @@ "punycode": { "version": "2.1.1", "resolved": "http://r.cnpmjs.org/punycode/download/punycode-2.1.1.tgz", - "integrity": "sha1-tYsBCsQMIsVldhbI0sLALHv0eew=", - "dev": true + "integrity": "sha1-tYsBCsQMIsVldhbI0sLALHv0eew=" }, "q": { "version": "1.5.1", @@ -11718,6 +11113,17 @@ "http-errors": "1.7.2", "iconv-lite": "0.4.24", "unpipe": "1.0.0" + }, + "dependencies": { + "iconv-lite": { + "version": "0.4.24", + "resolved": "http://r.cnpmjs.org/iconv-lite/download/iconv-lite-0.4.24.tgz", + "integrity": "sha1-ICK0sl+93CHS9SSXSkdKr+czkIs=", + "dev": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + } } }, "react-is": { @@ -11808,7 +11214,6 @@ "version": "2.3.7", "resolved": "http://r.cnpmjs.org/readable-stream/download/readable-stream-2.3.7.tgz", "integrity": "sha1-Hsoc9xGu+BTAT2IlKjamL2yyO1c=", - "dev": true, "requires": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", @@ -11890,12 +11295,6 @@ "es-abstract": "^1.17.0-next.1" } }, - "regexpp": { - "version": "3.1.0", - "resolved": "http://r.cnpmjs.org/regexpp/download/regexpp-3.1.0.tgz", - "integrity": "sha1-IG0K0KVkjP+9uK5GQ489xRyfeOI=", - "dev": true - }, "regexpu-core": { "version": "4.7.0", "resolved": "http://r.cnpmjs.org/regexpu-core/download/regexpu-core-4.7.0.tgz", @@ -12081,6 +11480,11 @@ "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=", "dev": true }, + "resize-observer-polyfill": { + "version": "1.5.1", + "resolved": "http://r.cnpmjs.org/resize-observer-polyfill/download/resize-observer-polyfill-1.5.1.tgz", + "integrity": "sha1-DpAg3T0hAkRY1OvSfiPkAmmBBGQ=" + }, "resolve": { "version": "1.17.0", "resolved": "http://r.cnpmjs.org/resolve/download/resolve-1.17.0.tgz", @@ -12164,21 +11568,42 @@ "inherits": "^2.0.1" } }, + "robust-orientation": { + "version": "1.1.3", + "resolved": "http://r.cnpmjs.org/robust-orientation/download/robust-orientation-1.1.3.tgz", + "integrity": "sha1-2v9bANO+TmByLw6cAVbvln8cIEk=", + "requires": { + "robust-scale": "^1.0.2", + "robust-subtract": "^1.0.0", + "robust-sum": "^1.0.0", + "two-product": "^1.0.2" + } + }, + "robust-scale": { + "version": "1.0.2", + "resolved": "http://r.cnpmjs.org/robust-scale/download/robust-scale-1.0.2.tgz", + "integrity": "sha1-d1Ey7QlULQKOWLLMecBikLz3jDI=", + "requires": { + "two-product": "^1.0.2", + "two-sum": "^1.0.0" + } + }, + "robust-subtract": { + "version": "1.0.0", + "resolved": "http://r.cnpmjs.org/robust-subtract/download/robust-subtract-1.0.0.tgz", + "integrity": "sha1-4LFk4e2LpOOl3aRaEgODSNvtPpo=" + }, + "robust-sum": { + "version": "1.0.0", + "resolved": "http://r.cnpmjs.org/robust-sum/download/robust-sum-1.0.0.tgz", + "integrity": "sha1-FmRuUlKStNJdgnV6KGlV4Lv6U9k=" + }, "rsvp": { "version": "4.8.5", "resolved": "http://r.cnpmjs.org/rsvp/download/rsvp-4.8.5.tgz", "integrity": "sha1-yPFVMR0Wf2jyHhaN9x7FsIMRNzQ=", "dev": true }, - "run-async": { - "version": "2.4.0", - "resolved": "http://r.cnpmjs.org/run-async/download/run-async-2.4.0.tgz", - "integrity": "sha1-5ZBUpbhods+uB/Qx0Yy63cWU8eg=", - "dev": true, - "requires": { - "is-promise": "^2.1.0" - } - }, "run-queue": { "version": "1.0.3", "resolved": "http://r.cnpmjs.org/run-queue/download/run-queue-1.0.3.tgz", @@ -12188,20 +11613,10 @@ "aproba": "^1.1.1" } }, - "rxjs": { - "version": "6.5.5", - "resolved": "http://r.cnpmjs.org/rxjs/download/rxjs-6.5.5.tgz", - "integrity": "sha1-xciE4wlMjP7jG/J+uH5UzPyH+ew=", - "dev": true, - "requires": { - "tslib": "^1.9.0" - } - }, "safe-buffer": { "version": "5.1.2", "resolved": "http://r.cnpmjs.org/safe-buffer/download/safe-buffer-5.1.2.tgz", - "integrity": "sha1-mR7GnSluAxN0fVm9/St0XDX4go0=", - "dev": true + "integrity": "sha1-mR7GnSluAxN0fVm9/St0XDX4go0=" }, "safe-regex": { "version": "1.1.0", @@ -12215,8 +11630,7 @@ "safer-buffer": { "version": "2.1.2", "resolved": "http://r.cnpmjs.org/safer-buffer/download/safer-buffer-2.1.2.tgz", - "integrity": "sha1-RPoWGwGHuVSd2Eu5GAL5vYOFzWo=", - "dev": true + "integrity": "sha1-RPoWGwGHuVSd2Eu5GAL5vYOFzWo=" }, "sane": { "version": "4.1.0", @@ -12443,6 +11857,11 @@ "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", "dev": true }, + "set-immediate-shim": { + "version": "1.0.1", + "resolved": "http://r.cnpmjs.org/set-immediate-shim/download/set-immediate-shim-1.0.1.tgz", + "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=" + }, "set-value": { "version": "2.0.1", "resolved": "http://r.cnpmjs.org/set-value/download/set-value-2.0.1.tgz", @@ -12565,25 +11984,6 @@ "integrity": "sha1-3lUoUaF1nfOo8gZTVEL17E3eq0Q=", "dev": true }, - "slice-ansi": { - "version": "2.1.0", - "resolved": "http://r.cnpmjs.org/slice-ansi/download/slice-ansi-2.1.0.tgz", - "integrity": "sha1-ys12k0YaY3pXiNkqfdT7oGjoFjY=", - "dev": true, - "requires": { - "ansi-styles": "^3.2.0", - "astral-regex": "^1.0.0", - "is-fullwidth-code-point": "^2.0.0" - }, - "dependencies": { - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "http://r.cnpmjs.org/is-fullwidth-code-point/download/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - } - } - }, "snapdragon": { "version": "0.8.2", "resolved": "http://r.cnpmjs.org/snapdragon/download/snapdragon-0.8.2.tgz", @@ -13101,7 +12501,6 @@ "version": "1.1.1", "resolved": "http://r.cnpmjs.org/string_decoder/download/string_decoder-1.1.1.tgz", "integrity": "sha1-nPFhG6YmhdcDCunkujQUnDrwP8g=", - "dev": true, "requires": { "safe-buffer": "~5.1.0" } @@ -13219,52 +12618,6 @@ "integrity": "sha1-QwY30ki6d+B4iDlR+5qg7tfGP6I=", "dev": true }, - "table": { - "version": "5.4.6", - "resolved": "http://r.cnpmjs.org/table/download/table-5.4.6.tgz", - "integrity": "sha1-EpLRlQDOP4YFOwXw6Ofko7shB54=", - "dev": true, - "requires": { - "ajv": "^6.10.2", - "lodash": "^4.17.14", - "slice-ansi": "^2.1.0", - "string-width": "^3.0.0" - }, - "dependencies": { - "emoji-regex": { - "version": "7.0.3", - "resolved": "http://r.cnpmjs.org/emoji-regex/download/emoji-regex-7.0.3.tgz", - "integrity": "sha1-kzoEBShgyF6DwSJHnEdIqOTHIVY=", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "http://r.cnpmjs.org/is-fullwidth-code-point/download/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, - "string-width": { - "version": "3.1.0", - "resolved": "http://r.cnpmjs.org/string-width/download/string-width-3.1.0.tgz", - "integrity": "sha1-InZ74htirxCBV0MG9prFG2IgOWE=", - "dev": true, - "requires": { - "emoji-regex": "^7.0.1", - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^5.1.0" - } - }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "http://r.cnpmjs.org/strip-ansi/download/strip-ansi-5.2.0.tgz", - "integrity": "sha1-jJpTb+tq/JYr36WxBKUJHBrZwK4=", - "dev": true, - "requires": { - "ansi-regex": "^4.1.0" - } - } - } - }, "tapable": { "version": "1.1.3", "resolved": "http://r.cnpmjs.org/tapable/download/tapable-1.1.3.tgz", @@ -13338,12 +12691,6 @@ "require-main-filename": "^2.0.0" } }, - "text-table": { - "version": "0.2.0", - "resolved": "http://r.cnpmjs.org/text-table/download/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", - "dev": true - }, "thenify": { "version": "3.3.0", "resolved": "http://r.cnpmjs.org/thenify/download/thenify-3.3.0.tgz", @@ -13379,11 +12726,10 @@ "integrity": "sha1-iQN8vJLFarGJJua6TLsgDhVnKmo=", "dev": true }, - "through": { - "version": "2.3.8", - "resolved": "http://r.cnpmjs.org/through/download/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", - "dev": true + "throttle-debounce": { + "version": "1.1.0", + "resolved": "http://r.cnpmjs.org/throttle-debounce/download/throttle-debounce-1.1.0.tgz", + "integrity": "sha1-UYU9o3vmihVctugns1FKPEIuic0=" }, "through2": { "version": "2.0.5", @@ -13416,15 +12762,6 @@ "integrity": "sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=", "dev": true }, - "tmp": { - "version": "0.0.33", - "resolved": "http://r.cnpmjs.org/tmp/download/tmp-0.0.33.tgz", - "integrity": "sha1-bTQzWIl2jSGyvNoKonfO07G/rfk=", - "dev": true, - "requires": { - "os-tmpdir": "~1.0.2" - } - }, "tmpl": { "version": "1.0.4", "resolved": "http://r.cnpmjs.org/tmpl/download/tmpl-1.0.4.tgz", @@ -13696,6 +13033,16 @@ "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", "dev": true }, + "two-product": { + "version": "1.0.2", + "resolved": "http://r.cnpmjs.org/two-product/download/two-product-1.0.2.tgz", + "integrity": "sha1-Z9ldSyV6kh4stL16+VEfkIhSLqo=" + }, + "two-sum": { + "version": "1.0.0", + "resolved": "http://r.cnpmjs.org/two-sum/download/two-sum-1.0.0.tgz", + "integrity": "sha1-MdPzIjnk9zHsqd+RVeKyl/AIq2Q=" + }, "type-check": { "version": "0.3.2", "resolved": "http://r.cnpmjs.org/type-check/download/type-check-0.3.2.tgz", @@ -13901,7 +13248,6 @@ "version": "4.2.2", "resolved": "http://r.cnpmjs.org/uri-js/download/uri-js-4.2.2.tgz", "integrity": "sha1-lMVA4f93KVbiKZUHwBCupsiDjrA=", - "dev": true, "requires": { "punycode": "^2.1.0" } @@ -13977,8 +13323,7 @@ "util-deprecate": { "version": "1.0.2", "resolved": "http://r.cnpmjs.org/util-deprecate/download/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, "util.promisify": { "version": "1.0.1", @@ -14010,12 +13355,6 @@ "integrity": "sha1-sj5DWK+oogL+ehAK8fX4g/AgB+4=", "dev": true }, - "v8-compile-cache": { - "version": "2.1.0", - "resolved": "http://r.cnpmjs.org/v8-compile-cache/download/v8-compile-cache-2.1.0.tgz", - "integrity": "sha1-4U3jezGm0ZT1aQ1n78Tn9vxqsw4=", - "dev": true - }, "validate-npm-package-license": { "version": "3.0.4", "resolved": "http://r.cnpmjs.org/validate-npm-package-license/download/validate-npm-package-license-3.0.4.tgz", @@ -14060,32 +13399,6 @@ "resolved": "http://r.cnpmjs.org/vue/download/vue-2.6.11.tgz", "integrity": "sha1-dllNh31LEiNEBuhONSdcbVFBJcU=" }, - "vue-eslint-parser": { - "version": "7.0.0", - "resolved": "http://r.cnpmjs.org/vue-eslint-parser/download/vue-eslint-parser-7.0.0.tgz", - "integrity": "sha1-pO0mafhxed7dBq/dhzasuzo4ZNY=", - "dev": true, - "requires": { - "debug": "^4.1.1", - "eslint-scope": "^5.0.0", - "eslint-visitor-keys": "^1.1.0", - "espree": "^6.1.2", - "esquery": "^1.0.1", - "lodash": "^4.17.15" - }, - "dependencies": { - "eslint-scope": { - "version": "5.0.0", - "resolved": "http://r.cnpmjs.org/eslint-scope/download/eslint-scope-5.0.0.tgz", - "integrity": "sha1-6HyIh8c+jR7ITxylkWRcNYv8j7k=", - "dev": true, - "requires": { - "esrecurse": "^4.1.0", - "estraverse": "^4.1.1" - } - } - } - }, "vue-hot-reload-api": { "version": "2.3.4", "resolved": "http://r.cnpmjs.org/vue-hot-reload-api/download/vue-hot-reload-api-2.3.4.tgz", @@ -14686,6 +13999,17 @@ "dev": true, "requires": { "iconv-lite": "0.4.24" + }, + "dependencies": { + "iconv-lite": { + "version": "0.4.24", + "resolved": "http://r.cnpmjs.org/iconv-lite/download/iconv-lite-0.4.24.tgz", + "integrity": "sha1-ICK0sl+93CHS9SSXSkdKr+czkIs=", + "dev": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + } } }, "whatwg-mimetype": { @@ -14735,6 +14059,26 @@ "errno": "~0.1.7" } }, + "worker-loader": { + "version": "2.0.0", + "resolved": "http://r.cnpmjs.org/worker-loader/download/worker-loader-2.0.0.tgz", + "integrity": "sha1-Rf2j73asqBV3GokQc5nuQRm0MKw=", + "requires": { + "loader-utils": "^1.0.0", + "schema-utils": "^0.4.0" + }, + "dependencies": { + "schema-utils": { + "version": "0.4.7", + "resolved": "http://r.cnpmjs.org/schema-utils/download/schema-utils-0.4.7.tgz", + "integrity": "sha1-unT1l9K+LqiAExdG7hfQoJPGgYc=", + "requires": { + "ajv": "^6.1.0", + "ajv-keywords": "^3.1.0" + } + } + } + }, "worker-rpc": { "version": "0.1.1", "resolved": "http://r.cnpmjs.org/worker-rpc/download/worker-rpc-0.1.1.tgz", @@ -14795,15 +14139,6 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, - "write": { - "version": "1.0.3", - "resolved": "http://r.cnpmjs.org/write/download/write-1.0.3.tgz", - "integrity": "sha1-CADhRSO5I6OH5BUSPIZWFqrg9cM=", - "dev": true, - "requires": { - "mkdirp": "^0.5.1" - } - }, "write-file-atomic": { "version": "2.4.1", "resolved": "http://r.cnpmjs.org/write-file-atomic/download/write-file-atomic-2.4.1.tgz", diff --git a/package.json b/package.json index 41fa452..7a57843 100644 --- a/package.json +++ b/package.json @@ -10,27 +10,26 @@ }, "dependencies": { "core-js": "^3.6.4", + "element-ui": "^2.13.1", + "iconv-lite": "^0.5.1", + "js-angusj-clipper": "^1.0.4", + "jszip": "^3.4.0", + "monotone-convex-hull-2d": "^1.0.1", "vue": "^2.6.11" }, "devDependencies": { "@types/jest": "^24.0.19", - "@typescript-eslint/eslint-plugin": "^2.26.0", - "@typescript-eslint/parser": "^2.26.0", + "@types/node": "^13.13.4", "@vue/cli-plugin-babel": "~4.3.0", - "@vue/cli-plugin-eslint": "~4.3.0", "@vue/cli-plugin-typescript": "~4.3.0", "@vue/cli-plugin-unit-jest": "~4.3.0", "@vue/cli-service": "~4.3.0", - "@vue/eslint-config-prettier": "^6.0.0", - "@vue/eslint-config-typescript": "^5.0.2", "@vue/test-utils": "1.0.0-beta.31", - "eslint": "^6.7.2", - "eslint-plugin-prettier": "^3.1.1", - "eslint-plugin-vue": "^6.2.2", "prettier": "^1.19.1", "sass": "^1.26.3", "sass-loader": "^8.0.2", "typescript": "~3.8.3", - "vue-template-compiler": "^2.6.11" + "vue-template-compiler": "^2.6.11", + "worker-loader": "^2.0.0" } } diff --git a/src/App.vue b/src/App.vue index d3a38c9..6d0f9d3 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,29 +1,64 @@ - - diff --git a/src/Business/BlockConvert.ts b/src/Business/BlockConvert.ts new file mode 100644 index 0000000..0cfd887 --- /dev/null +++ b/src/Business/BlockConvert.ts @@ -0,0 +1,21 @@ +import { Path } from '../Nest/Core/Path'; +import { Part } from '../Nest/Core/Part'; +export class BlockConvert{ + /** + * + */ + constructor() { + // super(); + + } + createPart(data:any,board:Path){ + let id = data['BlockID']; + let width = data['Width']; + let height = data['Length']; + let part = new Part(); + part.Id = id; + part.Init(new Path([{ x: 0, y: 0 }, { x: width, y: 0 }, { x: width, y: height }, { x: 0, y: height }]),board); + part.UserData = data; + return part; + } +} \ No newline at end of file diff --git a/src/Business/BlockView.ts b/src/Business/BlockView.ts new file mode 100644 index 0000000..54d70b7 --- /dev/null +++ b/src/Business/BlockView.ts @@ -0,0 +1,11 @@ +export class BlockView{ + /** + * + */ + constructor(canvas:HTMLCanvasElement) { + + } + drawBlock(){ + + } +} \ No newline at end of file diff --git a/src/Business/FileHelper.ts b/src/Business/FileHelper.ts new file mode 100644 index 0000000..e832c4c --- /dev/null +++ b/src/Business/FileHelper.ts @@ -0,0 +1,9 @@ +export async function readText(file:Blob,encoding?:string):Promise{ + return new Promise((resolve)=>{ + let fileReader = new FileReader(); + fileReader.onload=function(e){ + resolve(this.result); + } + fileReader.readAsText(file,encoding) + }) +} \ No newline at end of file diff --git a/src/Business/LayoutConfig.ts b/src/Business/LayoutConfig.ts new file mode 100644 index 0000000..b9eb4cd --- /dev/null +++ b/src/Business/LayoutConfig.ts @@ -0,0 +1,5 @@ +export class LayoutConfig{ + loadLegacyConfig(){ + + } +} \ No newline at end of file diff --git a/src/Business/LayoutEngine.ts b/src/Business/LayoutEngine.ts new file mode 100644 index 0000000..4d7040c --- /dev/null +++ b/src/Business/LayoutEngine.ts @@ -0,0 +1,88 @@ +import { Part } from '../Nest/Core/Part'; +import { Path } from '../Nest/Core/Path'; +import { DefaultBin } from '../Nest/Core/DefaultBin'; +import { PathGeneratorSingle } from '../Nest/Core/PathGenerator'; +import { NestCache } from '../Nest/Core/NestCache'; +import { NestDatabase } from '../Nest/Core/NestDatabase'; +import { NestFiler } from '../Nest/Common/Filer'; +import { OptimizeMachine } from '../Nest/Core/OptimizeMachine'; +import { Individual } from '../Nest/Core/Individual'; +import Worker from "../Nest/Core/OptimizeWorker.worker"; +import { InitClipperCpp } from '../Nest/Common/ClipperCpp'; + +export class LayoutEngine { + parts: Part[] = []; + board: Path; + threads: Worker[] = []; + /** + * + */ + constructor() { + + //清理缓存,这个缓存是全局的 + PathGeneratorSingle.Clear(); + NestCache.Clear(); + DefaultBin.InsideNFPCache = {}; + + //注册bin + let binPath = DefaultBin; + // binPath.Id = undefined; //清除这个缓存 + PathGeneratorSingle.RegisterId(binPath); + + this.board = binPath; + + } + init(parts: Part[]) { + this.parts = parts; + } + + async run() { + await InitClipperCpp(); + let m = new OptimizeMachine;//优化器 + m.Bin = this.board; //指定Bin容器 + m.PutParts(this.parts);//把零件放上去 + let count = 0; + m.callBack = async (i: Individual) => { + console.log('优化结果', i); + count++; + if(count>10){ + m.Suspend();//关闭优化器 + } + + }//当有新结果时,回调 + + await m.Start();//启动这个 + } + + async startThread() { + + let db = new NestDatabase(); + db.Paths = PathGeneratorSingle.paths; + db.Parts = this.parts; + db.Bin = DefaultBin + + let f = new NestFiler(); + db.WriteFile(f);//写入到文件中 + let best = Infinity; + + let t = new Worker; + this.threads = [t]; + + t.onmessage = (e) => { + let f = new NestFiler(e.data); + let inv = new Individual(db.Parts); + inv.ReadFile(f); + if (best <= inv.Fitness) + return; + best = inv.Fitness; + let text = `优化率:${inv.Fitness}`; + console.log(text); + }; + t.postMessage(f._datas);//Post给Worker + + } + + async stopThread() { + this.threads[0].terminate() + } +} \ No newline at end of file diff --git a/src/Common/ArrayExt.ts b/src/Common/ArrayExt.ts new file mode 100644 index 0000000..99e3155 --- /dev/null +++ b/src/Common/ArrayExt.ts @@ -0,0 +1,185 @@ +/** + * 删除数组中指定的元素,返回数组本身 + * @param {Array} arr 需要操作的数组 + * @param {*} el 需要移除的元素 + */ +export function arrayRemove(arr: Array, el: T): Array +{ + let j = 0; + for (let i = 0, l = arr.length; i < l; i++) + { + if (arr[i] !== el) + { + arr[j++] = arr[i]; + } + } + arr.length = j; + + return arr; +} + + +export function arrayRemoveOnce(arr: Array, el: T): Array +{ + let index = arr.indexOf(el); + if (index !== -1) + arr.splice(index, 1); + return arr; +} + +/** + * 删除通过函数校验的元素 + * @param {(e: T) => boolean} checkFuntion 校验函数 + */ +export function arrayRemoveIf(arr: Array, checkFuntion: (e: T) => boolean): Array +{ + let j = 0; + for (let i = 0, l = arr.length; i < l; i++) + { + if (!checkFuntion(arr[i])) + { + arr[j++] = arr[i]; + } + } + arr.length = j; + + return arr; +} + +export function arrayFirst(arr: Array): T +{ + return arr[0]; +} + +export function arrayLast(arr: { [key: number]: T, length: number; }): T +{ + return arr[arr.length - 1]; +} + +/** + * 根据数值从小到大排序数组 + * @param {Array} arr + * @returns {Array} 返回自身 + */ +export function arraySortByNumber(arr: Array): Array +{ + arr.sort(sortNumberCompart); + return arr; +} + +/** + * 对排序好的数组进行去重操作 + * @param {(e1, e2) => boolean} [checkFuction] 校验对象相等函数 + * @returns {Array} 返回自身 + */ +export function arrayRemoveDuplicateBySort(arr: Array, checkFuction: (e1: T, e2: T) => boolean = checkEqual): Array +{ + if (arr.length < 2) return arr; + let j = 1; + for (let i = 1, l = arr.length; i < l; i++) + if (!checkFuction(arr[j - 1], arr[i])) + arr[j++] = arr[i]; + arr.length = j; + return arr; +} + +/** + * 对排序好的数组进行去重操作 + * @param {(e1, e2) => boolean} [checkFuction] 校验对象相等函数 + * @returns {Array} 返回新数组 + */ +export function arrayRemoveDuplicateBySort2(arr: Array, checkFuction: (e1: T, e2: T) => boolean = checkEqual): Array +{ + if (arr.length < 2) return arr; + + let pre = arr[0], + newArr = [pre], + now: T; + + for (let i = 1, len = arr.length; i < len; i++) + { + now = arr[i]; + if (!checkFuction(pre, now)) + { + newArr.push(now); + pre = now; + } + } + + if (pre !== now) newArr.push(now); + + return newArr; +} + +//原地更新数组,注意这个函数并不会比map快. +export function arrayMap(arr: Array, mapFunc: (v: T) => T): Array +{ + for (let i = 0, count = arr.length; i < count; i++) + arr[i] = mapFunc(arr[i]); + return arr; +} + +function sortNumberCompart(e1: any, e2: any) +{ + return e1 - e2; +} + +function checkEqual(e1: any, e2: any): boolean +{ + return e1 === e2; +} + +/** + * 改变数组的值顺序 + * @param arr 需要改变初始值位置的数组 + * @param index //将index位置以后的值放到起始位置 + */ +export function changeArrayStartIndex(arr: T[], index: number): T[] +{ + arr.unshift(...arr.splice(index)); + return arr; +} + +export function equalArray(a: T[], b: T[], checkF = checkEqual) +{ + if (a === b) return true; + if (a.length !== b.length) return false; + for (var i = 0; i < a.length; ++i) + if (!checkF(a[i], b[i])) return false; + return true; +} + +export function arrayClone(arr: T[]): T[] +{ + return arr.slice(); +} + +//https://jsperf.com/merge-array-implementations/30 +export function arrayPushArray(arr1: T[], arr2: T[]): T[] +{ + let arr1Length = arr1.length; + let arr2Length = arr2.length; + arr1.length = arr1Length + arr2Length; + for (let i = 0; i < arr2Length; i++) + arr1[arr1Length + i] = arr2[i]; + + return arr1; +} + +export function arraySum(arr: number[]) +{ + let sum = 0; + for (let n of arr) sum += n; + return sum; +} + +export function FilterSet(s: Set, fn: (el: T) => boolean): Set +{ + let ns = new Set(); + for (let el of s) + { + if (fn(el)) + ns.add(el); + } + return ns; +} diff --git a/src/Common/Sleep.ts b/src/Common/Sleep.ts new file mode 100644 index 0000000..da1fcda --- /dev/null +++ b/src/Common/Sleep.ts @@ -0,0 +1,7 @@ +export async function Sleep(time: number) +{ + return new Promise(res => + { + setTimeout(res, time); + }); +} diff --git a/src/Nest/Common/Box2.ts b/src/Nest/Common/Box2.ts new file mode 100644 index 0000000..d3669d7 --- /dev/null +++ b/src/Nest/Common/Box2.ts @@ -0,0 +1,160 @@ +import { Vector2 } from "./Vector2"; +import { Point } from "./Point"; + +export class Box2 +{ + min: Vector2; + max: Vector2; + constructor(min = new Vector2(+ Infinity, + Infinity), max = new Vector2(- Infinity, - Infinity)) + { + this.min = min; + this.max = max; + } + + get area(): number + { + return (this.max.x - this.min.x) * (this.max.y - this.min.y); + } + + set(min: Vector2, max: Vector2): Box2 + { + this.min.copy(min); + this.max.copy(max); + return this; + } + setFromPoints(points: Vector2[]): Box2 + { + this.makeEmpty(); + for (let i = 0, il = points.length; i < il; i++) + { + this.expandByPoint(points[i]); + } + return this; + } + private static _setFromCenterAndSize_v1 = new Vector2(); + setFromCenterAndSize(center: Vector2, size: Vector2): Box2 + { + const v1 = Box2._setFromCenterAndSize_v1; + const halfSize = v1.copy(size).multiplyScalar(0.5); + this.min.copy(center).sub(halfSize); + this.max.copy(center).add(halfSize); + return this; + } + clone(): Box2 + { + return new (this.constructor as any)().copy(this); + } + copy(box: Box2): Box2 + { + this.min.copy(box.min); + this.max.copy(box.max); + return this; + } + makeEmpty(): Box2 + { + this.min.x = this.min.y = + Infinity; + this.max.x = this.max.y = - Infinity; + return this; + } + isEmpty(): boolean + { + // this is a more robust check for empty than (volume <= 0) because volume can get positive with two negative axes + return (this.max.x < this.min.x) || (this.max.y < this.min.y); + } + getCenter(result: Vector2 = new Vector2()): Vector2 + { + return this.isEmpty() ? result.set(0, 0) : result.addVectors(this.min, this.max).multiplyScalar(0.5); + } + getSize(result: Vector2 = new Vector2()): Vector2 + { + return this.isEmpty() ? result.set(0, 0) : result.subVectors(this.max, this.min); + } + expandByPoint(point: Vector2): Box2 + { + this.min.min(point); + this.max.max(point); + return this; + } + expandByVector(vector: Vector2): Box2 + { + this.min.sub(vector); + this.max.add(vector); + return this; + } + expandByScalar(scalar: number): Box2 + { + this.min.addScalar(- scalar); + this.max.addScalar(scalar); + return this; + } + containsPoint(point: Vector2): boolean + { + if (point.x < this.min.x || point.x > this.max.x || + point.y < this.min.y || point.y > this.max.y) + { + return false; + } + return true; + } + containsBox(box: Box2): boolean + { + if ((this.min.x <= box.min.x) && (box.max.x <= this.max.x) && + (this.min.y <= box.min.y) && (box.max.y <= this.max.y)) + { + return true; + } + return false; + } + getParameter(point: Vector2, result: Vector2 = new Vector2()): Vector2 + { + // This can potentially have a divide by zero if the box + // has a size dimension of 0. + return result.set( + (point.x - this.min.x) / (this.max.x - this.min.x), + (point.y - this.min.y) / (this.max.y - this.min.y) + ); + } + intersectsBox(box: Box2): boolean + { + // using 6 splitting planes to rule out intersections. + if (box.max.x < this.min.x || box.min.x > this.max.x || + box.max.y < this.min.y || box.min.y > this.max.y) + { + return false; + } + return true; + } + clampPoint(point: Vector2, result: Vector2 = new Vector2()): Vector2 + { + return result.copy(point).clamp(this.min, this.max); + } + private static _distanceToPoint_v1 = new Vector2(); + distanceToPoint(point: Vector2): number + { + const v1 = Box2._distanceToPoint_v1; + const clampedPoint = v1.copy(point).clamp(this.min, this.max); + return clampedPoint.sub(point).length(); + } + intersect(box: Box2): Box2 + { + this.min.max(box.min); + this.max.min(box.max); + return this; + } + union(box: Box2): Box2 + { + this.min.min(box.min); + this.max.max(box.max); + return this; + } + translate(offset: Point): Box2 + { + this.min.add(offset); + this.max.add(offset); + return this; + } + equals(box: Box2): boolean + { + return box.min.equals(this.min) && box.max.equals(this.max); + } +}; diff --git a/src/Nest/Common/ClipperCpp.ts b/src/Nest/Common/ClipperCpp.ts new file mode 100644 index 0000000..4a36576 --- /dev/null +++ b/src/Nest/Common/ClipperCpp.ts @@ -0,0 +1,21 @@ +import * as clipperLib from "js-angusj-clipper/web"; // nodejs style require + +export let clipperCpp: { lib?: clipperLib.ClipperLibWrapper; } = {}; +export function InitClipperCpp(): Promise +{ + if (clipperCpp.lib) return; + if (!globalThis.document) + globalThis.document = {} as any; + return new Promise((res, rej) => + { + clipperLib.loadNativeClipperLibInstanceAsync( + // let it autodetect which one to use, but also available WasmOnly and AsmJsOnly + clipperLib.NativeClipperLibRequestedFormat.WasmWithAsmJsFallback + ).then(c => + { + clipperCpp.lib = c; + res(); + console.log("载入成功!"); + }); + }); +} diff --git a/src/Nest/Common/ConvexHull2D.ts b/src/Nest/Common/ConvexHull2D.ts new file mode 100644 index 0000000..5045f85 --- /dev/null +++ b/src/Nest/Common/ConvexHull2D.ts @@ -0,0 +1,8 @@ +import { Point } from "./Point"; +import convexHull from 'monotone-convex-hull-2d'; +export function ConvexHull2D(points: Point[]): Point[] +{ + let pts = points.map(p => [p.x, p.y]); + let indexs: number[] = convexHull(pts); + return indexs.map(i => points[i]); +} diff --git a/src/Nest/Common/Filer.ts b/src/Nest/Common/Filer.ts new file mode 100644 index 0000000..a5a6ee4 --- /dev/null +++ b/src/Nest/Common/Filer.ts @@ -0,0 +1,30 @@ +/** + * CAD文件数据 + */ +export class NestFiler +{ + private readIndex: number = 0; + constructor(public _datas: any[] = []) { } + + Clear() + { + this._datas.length = 0; + return this.Reset(); + } + Reset() + { + this.readIndex = 0; + return this; + } + + Write(data: any) + { + this._datas.push(data); + return this; + } + + Read(): any + { + return this._datas[this.readIndex++]; + } +} diff --git a/src/Nest/Common/Point.ts b/src/Nest/Common/Point.ts new file mode 100644 index 0000000..5370c93 --- /dev/null +++ b/src/Nest/Common/Point.ts @@ -0,0 +1,6 @@ + +export interface Point +{ + x: number; + y: number; +} diff --git a/src/Nest/Common/Random.ts b/src/Nest/Common/Random.ts new file mode 100644 index 0000000..eb2573f --- /dev/null +++ b/src/Nest/Common/Random.ts @@ -0,0 +1,9 @@ +import { FixIndex } from "./Util"; + +export function RandomIndex(count: number, exclude?: number): number +{ + let index = Math.floor(Math.random() * count); + if (index === count) index = 0; + if (index === exclude) index = FixIndex(index + 1, count); + return index; +} diff --git a/src/Nest/Common/Shuffle.ts b/src/Nest/Common/Shuffle.ts new file mode 100644 index 0000000..85bf91c --- /dev/null +++ b/src/Nest/Common/Shuffle.ts @@ -0,0 +1,8 @@ +export function ShuffleArray(array: T[]) +{ + for (let i = array.length - 1; i > 0; i--) + { + const j = Math.floor(Math.random() * (i + 1)); + [array[i], array[j]] = [array[j], array[i]]; + } +} diff --git a/src/Nest/Common/Util.ts b/src/Nest/Common/Util.ts new file mode 100644 index 0000000..6c4e2f4 --- /dev/null +++ b/src/Nest/Common/Util.ts @@ -0,0 +1,35 @@ +export function equaln(v1: number, v2: number, fuzz = 1e-5) +{ + return Math.abs(v1 - v2) <= fuzz; +} + +export function FixIndex(index: number, arr: Array | number) +{ + let count = (arr instanceof Array) ? arr.length : arr; + if (index < 0) + return count + index; + else if (index >= count) + return index - count; + else + return index; +} + +/** + * @param compart 如果t2大于t1那么返回t2 + * @returns 索引 + */ +export function Max(arr: T[], compart: (t1: T, t2: T) => boolean): number +{ + let best: T = arr[0]; + let bestIndex = 0; + for (let i = 1; i < arr.length; i++) + { + let t1 = arr[i]; + if (compart(best, t1)) + { + best = t1; + bestIndex = i; + } + } + return bestIndex; +} diff --git a/src/Nest/Common/Vector2.ts b/src/Nest/Common/Vector2.ts new file mode 100644 index 0000000..0d5b283 --- /dev/null +++ b/src/Nest/Common/Vector2.ts @@ -0,0 +1,287 @@ +import { Point } from "./Point"; + +export class Vector2 +{ + x: number; + y: number; + readonly isVector2: boolean = true; + constructor(x: number = 0, y: number = 0) + { + this.x = x; + this.y = y; + } + get width(): number { return this.x; } + set width(value: number) { this.x = value; } + get height(): number { return this.y; } + set height(value: number) { this.y = value; } + set(x: number, y: number): Vector2 + { + this.x = x; + this.y = y; + return this; + } + setScalar(scalar: number): Vector2 + { + this.x = scalar; + this.y = scalar; + return this; + } + setX(x: number): Vector2 + { + this.x = x; + return this; + } + setY(y: number): Vector2 + { + this.y = y; + return this; + } + setComponent(index: number, value: number): Vector2 + { + switch (index) + { + case 0: this.x = value; break; + case 1: this.y = value; break; + default: throw new Error('index is out of range: ' + index); + } + return this; + } + getComponent(index: number): number + { + switch (index) + { + case 0: return this.x; + case 1: return this.y; + default: throw new Error('index is out of range: ' + index); + } + } + clone(): Vector2 + { + return new (this.constructor as any)().copy(this); + } + copy(v: Vector2): Vector2 + { + this.x = v.x; + this.y = v.y; + return this; + } + add(v: Point): Vector2 + { + this.x += v.x; + this.y += v.y; + return this; + } + addScalar(s: number): Vector2 + { + this.x += s; + this.y += s; + return this; + } + addVectors(a: Vector2, b: Vector2): Vector2 + { + this.x = a.x + b.x; + this.y = a.y + b.y; + return this; + } + addScaledVector(v: Vector2, s: number): Vector2 + { + this.x += v.x * s; + this.y += v.y * s; + return this; + } + sub(v: Vector2): Vector2 + { + this.x -= v.x; + this.y -= v.y; + return this; + } + subScalar(s: number): Vector2 + { + this.x -= s; + this.y -= s; + return this; + } + subVectors(a: Vector2, b: Vector2): Vector2 + { + this.x = a.x - b.x; + this.y = a.y - b.y; + return this; + } + multiply(v: Vector2): Vector2 + { + this.x *= v.x; + this.y *= v.y; + return this; + } + multiplyScalar(scalar: number): Vector2 + { + if (isFinite(scalar)) + { + this.x *= scalar; + this.y *= scalar; + } else + { + this.x = 0; + this.y = 0; + } + return this; + } + divide(v: Vector2): Vector2 + { + this.x /= v.x; + this.y /= v.y; + return this; + } + divideScalar(scalar: number): Vector2 + { + return this.multiplyScalar(1 / scalar); + } + min(v: Vector2): Vector2 + { + this.x = Math.min(this.x, v.x); + this.y = Math.min(this.y, v.y); + return this; + } + max(v: Vector2): Vector2 + { + this.x = Math.max(this.x, v.x); + this.y = Math.max(this.y, v.y); + return this; + } + clamp(min: Vector2, max: Vector2): Vector2 + { + // This function assumes min < max, if this assumption isn't true it will not operate correctly + this.x = Math.max(min.x, Math.min(max.x, this.x)); + this.y = Math.max(min.y, Math.min(max.y, this.y)); + return this; + } + private static clampScalar_min = new Vector2(); + private static clampScalar_max = new Vector2(); + clampScalar(minVal: number, maxVal: number): Vector2 + { + const min: Vector2 = Vector2.clampScalar_min.set(minVal, minVal); + const max: Vector2 = Vector2.clampScalar_max.set(maxVal, maxVal); + return this.clamp(min, max); + } + clampLength(min: number, max: number): Vector2 + { + const length: number = this.length(); + return this.multiplyScalar(Math.max(min, Math.min(max, length)) / length); + } + floor(): Vector2 + { + this.x = Math.floor(this.x); + this.y = Math.floor(this.y); + return this; + } + ceil(): Vector2 + { + this.x = Math.ceil(this.x); + this.y = Math.ceil(this.y); + return this; + } + round(): Vector2 + { + this.x = Math.round(this.x); + this.y = Math.round(this.y); + return this; + } + roundToZero(): Vector2 + { + this.x = (this.x < 0) ? Math.ceil(this.x) : Math.floor(this.x); + this.y = (this.y < 0) ? Math.ceil(this.y) : Math.floor(this.y); + return this; + } + negate(): Vector2 + { + this.x = - this.x; + this.y = - this.y; + return this; + } + dot(v: Vector2): number + { + return this.x * v.x + this.y * v.y; + } + lengthSq(): number + { + return this.x * this.x + this.y * this.y; + } + length(): number + { + return Math.sqrt(this.x * this.x + this.y * this.y); + } + lengthManhattan(): number + { + return Math.abs(this.x) + Math.abs(this.y); + } + normalize(): Vector2 + { + return this.divideScalar(this.length()); + } + angle(): number + { + // computes the angle in radians with respect to the positive x-axis + let angle: number = Math.atan2(this.y, this.x); + if (angle < 0) angle += 2 * Math.PI; + return angle; + } + distanceTo(v: Vector2): number + { + return Math.sqrt(this.distanceToSquared(v)); + } + distanceToSquared(v: Vector2): number + { + const dx: number = this.x - v.x, dy: number = this.y - v.y; + return dx * dx + dy * dy; + } + distanceToManhattan(v: Vector2): number + { + return Math.abs(this.x - v.x) + Math.abs(this.y - v.y); + } + setLength(length: number): Vector2 + { + return this.multiplyScalar(length / this.length()); + } + lerp(v: Vector2, alpha: number): Vector2 + { + this.x += (v.x - this.x) * alpha; + this.y += (v.y - this.y) * alpha; + return this; + } + lerpVectors(v1: Vector2, v2: Vector2, alpha: number): Vector2 + { + return this.subVectors(v2, v1).multiplyScalar(alpha).add(v1); + } + equals(v: Vector2): boolean + { + return ((v.x === this.x) && (v.y === this.y)); + } + fromArray(array: Float32Array | number[], offset: number = 0): Vector2 + { + this.x = array[offset]; + this.y = array[offset + 1]; + return this; + } + toArray(array: Float32Array | number[] = [], offset: number = 0): Float32Array | number[] + { + array[offset] = this.x; + array[offset + 1] = this.y; + return array; + } + fromAttribute(attribute: any, index: number, offset: number = 0): Vector2 + { + index = index * attribute.itemSize + offset; + this.x = attribute.array[index]; + this.y = attribute.array[index + 1]; + return this; + } + rotateAround(center: Vector2, angle: number): Vector2 + { + const c: number = Math.cos(angle), s: number = Math.sin(angle); + const x: number = this.x - center.x; + const y: number = this.y - center.y; + this.x = x * c - y * s + center.x; + this.y = x * s + y * c + center.y; + return this; + } +} diff --git a/src/Nest/Core/Container.ts b/src/Nest/Core/Container.ts new file mode 100644 index 0000000..3bc746f --- /dev/null +++ b/src/Nest/Core/Container.ts @@ -0,0 +1,373 @@ +import { ClipType, PolyFillType, Paths } from "js-angusj-clipper/web"; +import { SubjectInput } from "js-angusj-clipper/web/clipFunctions"; +import { Box2 } from "../Common/Box2"; +import { clipperCpp } from "../Common/ClipperCpp"; +import { ConvexHull2D } from "../Common/ConvexHull2D"; +import { NestFiler } from "../Common/Filer"; +import { NestCache } from "./NestCache"; +import { Part } from "./Part"; +import { Area, Path, TranslatePath } from "./Path"; +import { PlaceType } from "./PlaceType"; +import { Point } from "../Common/Point"; +import { equaln } from "../Common/Util"; +import { Vector2 } from "../Common/Vector2"; + +/** + * 当零件尝试放置后容器的状态,用于尝试放置,并且尝试贪心 + */ +interface PartPlacedContainerState +{ + p: Point; + area?: number; + hull?: Point[]; + box?: Box2; +} + +/** + * 排料零件的容器,用来放置零件 + * 它是一块大板 + * 也可以是一个网洞 + * 也可以是余料 + */ +export class Container +{ + ParentId: number = -1;//父亲id,-1表示默认的bin,-2开始表示余料,大于等于0表示板件 + ChildrenIndex: number = 0;//网洞的索引位置 + ParentM: Point; + + Placed: Part[] = []; + PlaceType: PlaceType = PlaceType.Box; + + //放置状态 + PlacedArea = 0; + PlacedBox: Box2; + PlacedHull: Point[]; + + StatusKey: string; + constructor(protected BinPath?: Path) + { + if (BinPath) + this.StatusKey = this.BinPath.Id.toString() + "," + this.PlaceType; + } + + get UseRatio(): number + { + return this.PlacedBox.area / this.BinPath.Area; + } + + private _NotPuts: Set[] = [];//已经无法放置的pathId + + private PrePut(part: Part): PartPlacedContainerState + { + //无法容纳 + if (this.BinPath.Area - this.PlacedArea < part.State.Contour.Area) + return; + + let cacheKey = this.StatusKey + "," + part.State.Contour.Id; + let cacheP = NestCache.PositionCache[cacheKey]; + //读取缓存位置 + if (cacheP) + { + NestCache.count1++; + return this.Calc(part, cacheP); + } + + let binNfp = this.BinPath.GetInsideNFP(part.State.Contour); + if (!binNfp || binNfp.length === 0) return; + + //首个 + if (this.Placed.length === 0) + { + let p = this.GetFarLeftP(binNfp); + NestCache.PositionCache[cacheKey] = p; + return this.Calc(part, p); + } + + //快速退出 + let noSet = NestCache.NoPutCache[this.StatusKey]; + if (noSet) this._NotPuts.push(noSet); + for (let set of this._NotPuts) + { + if (set.has(part.State.Contour.Id)) + { + NestCache.count2++; + return; + } + } + + let finalNfp = this.GetNFPs(part, binNfp); + if (!finalNfp || finalNfp.length === 0) + { + if (noSet) noSet.add(part.State.Contour.Id); + else + { + noSet = new Set([part.State.Contour.Id]); + NestCache.NoPutCache[this.StatusKey] = noSet; + } + return; + } + + //选择合适的放置点 + let minArea: number = Infinity; + let translate: Point; + let bestBox: Box2; + let bestHull: Point[]; + + let tempVec = new Vector2; + for (let nfp of finalNfp) + { + for (let p of nfp) + { + tempVec.set(p.x * 1e-4, p.y * 1e-4); + switch (this.PlaceType) + { + case PlaceType.Box: + { + let box2 = part.State.Contour.BoundingBox.clone(); + box2.translate(tempVec); + let rectBox = this.PlacedBox.clone().union(box2); + let size = rectBox.getSize(); + let area = size.x * size.y; + if (area < minArea || + ((equaln(area, minArea, 1)) + && (p.x < translate.x || (p.x === translate.x && p.y < translate.y)))) + // && (p.y < translate.y || (p.y === translate.y && p.x < translate.x)))) + // && (this.BinPath.Size.x > this.BinPath.Size.y ? p.x < translate.x : p.y < translate.y))) + { + translate = p; + minArea = area; + bestBox = rectBox; + } + break; + } + case PlaceType.Hull: + { + let pts = TranslatePath(part.State.Contour.Points, tempVec); + let nhull = ConvexHull2D([...pts, ...this.PlacedHull]); + let area = Math.abs(Area(nhull)); + if (area < minArea || + ((equaln(area, minArea, 1)) + && (p.x < translate.x || (p.x === translate.x && p.y < translate.y)))) + // && (p.y < translate.y || (p.y === translate.y && p.x < translate.x)))) + // && (this.BinPath.Size.x > this.BinPath.Size.y ? p.x < translate.x : p.y < translate.y))) + { + translate = p; + minArea = area; + bestHull = nhull; + } + break; + } + case PlaceType.Gravity: + { + if (!translate || p.x < translate.x || (p.x === translate.x && p.y < translate.y)) + translate = p; + } + default: + break; + } + } + } + + if (translate) + { + NestCache.PositionCache[cacheKey] = translate; + if (!bestBox) + bestBox = this.PlacedBox.clone().union(part.State.Contour.BoundingBox.clone().translate({ x: translate.x * 1e-4, y: translate.y * 1e-4 })); + return { p: translate, area: minArea, box: bestBox, hull: bestHull }; + } + } + + private Calc(part: Part, p: Point): PartPlacedContainerState + { + let d: PartPlacedContainerState = { p }; + + let m: Point = { x: p.x * 1e-4, y: p.y * 1e-4 }; + + if (this.PlacedBox) + d.box = this.PlacedBox.clone().union(part.State.Contour.BoundingBox.clone().translate(m)); + else + d.box = part.State.Contour.BoundingBox.clone().translate(m); + + //凸包 + if (this.PlaceType === PlaceType.Hull) + { + if (!this.PlacedHull) + { + d.hull = TranslatePath(part.State.Contour.Points, m); + d.area = part.State.Contour.Area; + } + else + { + d.hull = ConvexHull2D([...this.PlacedHull, ...TranslatePath(part.State.Contour.Points, m)]); + d.area = Area(d.hull); + } + + d.area = Math.abs(d.area); + } + else + { + d.area = d.box.area; + } + return d; + } + + PutPart(p: Part, greedy = false): boolean + { + let bestD: PartPlacedContainerState; + if (greedy) + { + let bestI: number; + for (let i = 0; i < p.RotatedStates.length; i++) + { + p.StateIndex = i; + let d = this.PrePut(p); + if (d && (!bestD || bestD.area > d.area || + ( + this.PlaceType === PlaceType.Hull + && equaln(bestD.area, d.area, 0.1) + && d.box.area < bestD.box.area + ) + )) + { + bestD = d; + bestI = i; + } + } + if (bestD) + p.StateIndex = bestI; + } + else + bestD = this.PrePut(p); + + if (bestD) + { + p.PlacePosition = bestD.p; + this.PlacedBox = bestD.box ?? this.PlacedBox; + this.PlacedHull = bestD.hull; + this.AppendPart(p, false); + return true; + } + return false; + } + + protected GetNFPs(part: Part, binNfp: Point[][]): Paths + { + //合并(零件和所有已经放置零件的NFP) + let nfps: SubjectInput[] = []; + for (let placedPart of this.Placed) + { + let nfp = placedPart.State.Contour.GetOutsideNFP(part.State.Contour); + if (!nfp) return; + for (let n of nfp) + { + let nnfp = TranslatePath(n, placedPart.PlacePosition); + nfps.push({ data: nnfp, closed: true }); + } + } + //合并nfp + let combinedNfp = clipperCpp.lib.clipToPaths({ + subjectInputs: nfps, + clipType: ClipType.Union, + subjectFillType: PolyFillType.NonZero + }); + + combinedNfp = clipperCpp.lib.cleanPolygons(combinedNfp, 100); + + if (combinedNfp.length === 0) return; + + //减去nfp + let finalNfp = clipperCpp.lib.clipToPaths({ + subjectInputs: [{ data: binNfp, closed: true }], + clipInputs: [{ data: combinedNfp }], + clipType: ClipType.Difference, + subjectFillType: PolyFillType.NonZero + }); + finalNfp = clipperCpp.lib.cleanPolygons(finalNfp, 100); + return finalNfp; + } + + /** + * 将Part添加的Placed列表 + * @param part 零件,已经计算了放置状态 + * @param [calc=true] 是否计算当前的容器状态? + */ + private AppendPart(part: Part, calc = true): void + { + this.StatusKey += "," + part.State.Contour.Id; + this.Placed.push(part); + this.PlacedArea += part.State.Contour.Area; + let m = { x: part.PlacePosition.x * 1e-4, y: part.PlacePosition.y * 1e-4 }; + if (calc) + { + //凸包 + if (this.PlaceType === PlaceType.Hull) + { + if (!this.PlacedHull) + this.PlacedHull = TranslatePath(part.State.Contour.Points, m); + else + this.PlacedHull = ConvexHull2D([...this.PlacedHull, ...TranslatePath(part.State.Contour.Points, m)]); + } + } + if (calc || this.PlaceType !== PlaceType.Box) + { + if (this.PlacedBox) + this.PlacedBox.union(part.State.Contour.BoundingBox.clone().translate(m)); + else + this.PlacedBox = part.State.Contour.BoundingBox.clone().translate(m); + } + } + + /** + * 得到最左边的点 + */ + protected GetFarLeftP(nfp: Point[][]): Point + { + let leftP: Point = { x: Infinity, y: Infinity }; + for (let path of nfp) + { + for (let p of path) + { + if (p.x < leftP.x) + leftP = p; + else if (p.x === leftP.x && p.y < leftP.y) + leftP = p; + } + } + return leftP; + } + + //#region -------------------------File------------------------- + //对象从文件中读取数据,初始化自身 + ReadFile(file: NestFiler, parts: Part[]) + { + this.ParentId = file.Read(); + this.ChildrenIndex = file.Read(); + this.ParentM = file.Read(); + let count = file.Read() as number; + this.Placed = []; + for (let i = 0; i < count; i++) + { + let index = file.Read() as number; + let part = parts[index]; + part.StateIndex = file.Read(); + part.PlacePosition = file.Read(); + this.Placed.push(part); + } + return this; + } + //对象将自身数据写入到文件. + WriteFile(file: NestFiler) + { + file.Write(this.ParentId); + file.Write(this.ChildrenIndex); + file.Write(this.ParentM); + file.Write(this.Placed.length); + for (let p of this.Placed) + { + file.Write(p.Id); + file.Write(p.StateIndex); + file.Write(p.PlacePosition); + } + } + //#endregion +} diff --git a/src/Nest/Core/DefaultBin.ts b/src/Nest/Core/DefaultBin.ts new file mode 100644 index 0000000..7a817bc --- /dev/null +++ b/src/Nest/Core/DefaultBin.ts @@ -0,0 +1,4 @@ +import { Path } from "./Path"; +let width = 1221; +let height = 2441; +export let DefaultBin = new Path([{ x: 0, y: 0 }, { x: width, y: 0 }, { x: width, y: height }, { x: 0, y: height }]); diff --git a/src/Nest/Core/Individual.ts b/src/Nest/Core/Individual.ts new file mode 100644 index 0000000..b964d2f --- /dev/null +++ b/src/Nest/Core/Individual.ts @@ -0,0 +1,190 @@ +import { arrayLast } from "../../Common/ArrayExt"; +import { Container } from "./Container"; +import { NestFiler } from "../Common/Filer"; +import { Part } from "./Part"; +import { Path } from "./Path"; +import { PlaceType } from "./PlaceType"; +import { RandomIndex } from "../Common/Random"; + +/** + * 个体(表示某一次优化的结果,或者还没开始优化的状态) + * 个体是由一堆零件组成的,零件可以有不同的状态。 + * + * 个体单独变异 + * 可以是某个零件的旋转状态发生改变 + * 可以是零件的顺序发生改变 + * + * 个体交配(感觉暂时不需要) + * 个体和其他个体进行基因交换 + */ +export class Individual +{ + //强壮程度 越低越好 + Fitness: number; + constructor(public Parts?: Part[], public mutationRate = 0.5) { } + + Clone() + { + let p = new Individual(this.Parts.map(p => p.Clone(), this.mutationRate)); + p.Mutate(); + return p; + } + + /** + * 突变 + */ + Mutate() + { + if (this.mutationRate > 0.5) + for (let i = 0; i < this.Parts.length; i++) + { + let rand = Math.random(); + if (rand < this.mutationRate * 0.5) + { + //和下一个调换顺序 + let j = i + 1; + if (j < this.Parts.length) + [this.Parts[i], this.Parts[j]] = [this.Parts[j], this.Parts[i]]; + } + if (rand < this.mutationRate) + this.Parts[i].Mutate(); + } + else + { + //洗牌 + let rand = Math.random(); + if (rand < 0.5) + { + let index = RandomIndex(this.Parts.length - 2); + let count = Math.ceil(RandomIndex(this.Parts.length - 2 - index) * this.mutationRate * 2) || 1; + let parts = this.Parts.splice(index, count); + this.Parts.push(...parts); + this.Parts[index].Mutate(); + } + else + for (let i = 0; i < this.Parts.length; i++) + { + let rand = Math.random(); + if (rand < this.mutationRate) + { + this.Parts[i].Mutate(); + i += 5; + } + } + } + + if (this.mutationRate > 0.2) + this.mutationRate -= 0.004; + return this; + } + + Containers: Container[]; + HoleContainers: Container[]; + /** + * 评估健康程度 + */ + Evaluate(bin: Path, bestCount: number, greedy = false, type?: PlaceType) + { + let parts = this.Parts; + this.Containers = []; + this.HoleContainers = []; + for (let part of parts) + { + for (let i = 0; i < part.Holes.length; i++) + { + let hole = part.Holes[i]; + let container = new Container(hole.Contour); + container.ParentId = part.Id; + container.ChildrenIndex = i; + container.ParentM = hole.OrigionMinPoint; + this.HoleContainers.push(container); + } + } + + //网洞优先 + parts = parts.filter(p => + { + for (let hole of this.HoleContainers) + { + if (hole.PutPart(p)) + return false; + } + return true; + }); + + while (parts.length > 0) + { + if (this.Containers.length > bestCount) + { + this.Fitness = Math.ceil(bestCount) + 1; + return; + } + let container = new Container(bin); + container.ParentId = -1; + if (greedy) + container.PlaceType = type; + else + container.PlaceType = RandomIndex(2); + if (this.mutationRate > 0.5) + { + let area = 0; + let maxP: Part; + for (let i = 0; i < parts.length; i++) + { + let p = parts[i]; + if (p.State.Contour.Area > area) + { + maxP = parts[i]; + area = p.State.Contour.Area; + } + } + if (container.PutPart(maxP, greedy)) + parts = parts.filter(p => p !== maxP); + } + parts = parts.filter(p => + { + return container.PutPart(p, greedy) !== true; + }); + if (!greedy) + { + parts = parts.filter(p => + { + return container.PutPart(p, true) !== true; + }); + } + this.Containers.push(container); + } + this.Fitness = this.Containers.length - 1 + arrayLast(this.Containers).UseRatio; + } + + //#region -------------------------File------------------------- + + //对象从文件中读取数据,初始化自身 + ReadFile(file: NestFiler) + { + this.Fitness = file.Read(); + let count = file.Read() as number; + this.Containers = []; + for (let i = 0; i < count; i++) + this.Containers.push(new Container().ReadFile(file, this.Parts)); + + count = file.Read(); + this.HoleContainers = []; + for (let i = 0; i < count; i++) + this.HoleContainers.push(new Container().ReadFile(file, this.Parts)); + } + + //对象将自身数据写入到文件. + WriteFile(f: NestFiler) + { + f.Write(this.Fitness); + f.Write(this.Containers.length); + for (let c of this.Containers) + c.WriteFile(f); + + f.Write(this.HoleContainers.length); + for (let c of this.HoleContainers) + c.WriteFile(f); + } + //#endregion +} diff --git a/src/Nest/Core/NestCache.ts b/src/Nest/Core/NestCache.ts new file mode 100644 index 0000000..43da019 --- /dev/null +++ b/src/Nest/Core/NestCache.ts @@ -0,0 +1,37 @@ +import { Path } from "./Path"; +import { Point } from "../Common/Point"; + +export class NestCache +{ + static count1 = 0; + static count2 = 0;//noset + + static PositionCache: { [key: string]: Point; } = {}; + static NoPutCache: { [key: string]: Set; } = {}; + private static CacheRect = new Map(); + + /** + * 用于创建原点在0点的矩形路径 + */ + static CreatePath(x: number, y: number, knifRadius = 3.5): Path + { + let minX = -knifRadius; + let maxX = x + knifRadius; + let minY = -knifRadius; + let maxY = y + knifRadius; + return new Path([ + { x: minX, y: minY }, + { x: maxX, y: minY }, + { x: maxX, y: maxY }, + { x: minX, y: maxY }, + ]); + } + + static Clear() + { + this.count1 = 0; + this.count2 = 0; + this.CacheRect.clear(); + this.PositionCache = {}; + } +} diff --git a/src/Nest/Core/NestDatabase.ts b/src/Nest/Core/NestDatabase.ts new file mode 100644 index 0000000..612458f --- /dev/null +++ b/src/Nest/Core/NestDatabase.ts @@ -0,0 +1,54 @@ +import { Part } from "./Part"; +import { Path } from "./Path"; +import { NestFiler } from "../Common/Filer"; +import { PathGeneratorSingle } from "./PathGenerator"; + +/** + * 排料数据库,用这个类来序列化需要排料的数据 + * 用于在Work间传输 + */ +export class NestDatabase +{ + Paths: Path[]; //所有的Path都在这里 + Bin: Path; //默认的容器 + Parts: Part[]; //所有的零件 + + //#region -------------------------File------------------------- + //对象从文件中读取数据,初始化自身 + ReadFile(file: NestFiler) + { + file.Read(); + let count = file.Read() as number; + this.Paths = []; + for (let i = 0; i < count; i++) + { + let path = new Path(); + path.ReadFile(file); + this.Paths.push(path); + } + this.Bin = this.Paths[file.Read()]; + PathGeneratorSingle.paths = this.Paths; + count = file.Read(); + this.Parts = []; + for (let i = 0; i < count; i++) + { + let part = new Part(); + part.ReadFile(file); + this.Parts.push(part); + } + } + //对象将自身数据写入到文件. + WriteFile(file: NestFiler) + { + file.Write(1); + file.Write(this.Paths.length); + for (let path of this.Paths) + path.WriteFile(file); + + file.Write(this.Bin.Id); + file.Write(this.Parts.length); + for (let part of this.Parts) + part.WriteFile(file); + } + //#endregion +} diff --git a/src/Nest/Core/OptimizeMachine.ts b/src/Nest/Core/OptimizeMachine.ts new file mode 100644 index 0000000..ba90d7f --- /dev/null +++ b/src/Nest/Core/OptimizeMachine.ts @@ -0,0 +1,160 @@ +import { arrayRemoveIf } from "../../Common/ArrayExt"; +import { Sleep } from "../../Common/Sleep"; +import { clipperCpp } from "../Common/ClipperCpp"; +import { Individual } from "./Individual"; +import { NestCache } from "./NestCache"; +import { Part } from "./Part"; +import { Path } from "./Path"; + +/** + * 优化器 + * 配置优化器 + * 放入零件 + * 按下启动 + * 按下暂停 + * 清理机台 + */ +export class OptimizeMachine +{ + //配置 + Config: { + PopulationCount: number;//种群个数 + }; + //容器板 + Bin: Path; + //机台上的零件 + Parts: Part[]; + private _IsSuspend = false; + + protected _Individuals: Individual[]; + + constructor() + { + this.Config = { PopulationCount: 50 }; + } + + //放入零件 + PutParts(parts: Part[]) + { + if (globalThis.document) parts = parts.slice(); + arrayRemoveIf(parts, p => p.RotatedStates.length === 0); + this.Parts = parts; + } + + callBack: (i: Individual) => Promise; + + //启动 + async Start() + { + if (this.Parts.length === 0) return; + console.log(this.Parts.length); + this._IsSuspend = false; + NestCache.Clear(); + this.Parts.sort((p1, p2) => p2.State.Contour.Area - p1.State.Contour.Area); + this._Individuals = [new Individual(this.Parts, 0.8)]; + for (let i = 1; i < this.Config.PopulationCount; i++) + { + let parts = this.Parts.map(p => p.Clone()); + if (i < 3) + { + for (let i = parts.length - 1; i > 0; i--) + { + const j = Math.floor(Math.random() * (i + 1)); + [parts[i], parts[j]] = [parts[j], parts[i]]; + parts[i].Mutate(); + } + } + this._Individuals.push(new Individual(parts, 0.8)); + } + //2.执行 + await this.Run(); + } + + calcCount = 0; + best = Infinity; + bestP: Individual; + bestCount = 0; + private async Run() + { + console.time("1"); + if (this.Parts.length === 0) return; + //开始自然选择 + while (!this._IsSuspend) //实验停止信号 + { + let goBack = this.calcCount - this.bestCount > 8000; + //1.适应环境(放置零件) + for (let i = 0; i < this._Individuals.length; i++) + { + if (globalThis.document || !clipperCpp.lib) + await Sleep(0); + let p = this._Individuals[i]; + if (this.calcCount < 1000 || this.calcCount % 1000 === 0) + p.Evaluate(this.Bin, this.best, true, i % 2); + else + p.Evaluate(this.Bin, this.best); + + if (!this.bestP || p.Fitness < this.bestP.Fitness) + { + this.bestP = p; + this.best = p.Fitness; + await this.callBack(p); + } + if (goBack) + p.mutationRate = 0.5; + } + + this.calcCount += this._Individuals.length; + if (this.calcCount % 100 === 0) + { + console.timeLog("1", this.bestP.Fitness, this.calcCount, NestCache.count1, NestCache.count2); + await Sleep(0); + } + + this._Individuals.sort((i1, i2) => i1.Fitness - i2.Fitness); + let bestP = this._Individuals[0]; + // //回调最好的 + // if (bestP.Fitness < this.best) + // { + // this.best = bestP.Fitness; + // this.bestP = bestP; + // // console.timeLog("1", this.best, this.calcCount, NestCache.count1, NestCache.count2); + // if (this.callBack) + // await this.callBack(bestP); + // } + + //自然选择 + this._Individuals.splice(-10);//杀死它 + for (let i = 0; i < 4; i++) + this._Individuals.push(bestP.Clone()); + this._Individuals.push(this.bestP.Clone()); + for (let i = 0; i < 3; i++) + this._Individuals.push(this._Individuals[1].Clone()); + for (let i = 0; i < 2; i++) + this._Individuals.push(this._Individuals[2].Clone()); + //全部突变 + for (let p of this._Individuals) + { + if (p.Fitness !== undefined) + p.Mutate(); + } + } + } + //暂停 + Suspend() + { + console.timeEnd("1"); + console.log(this.best, this.calcCount, NestCache.count1); + this._IsSuspend = true; + console.log("暂停"); + } + //继续 + Continue() + { + this._IsSuspend = false; + this.Run(); + } + //清理机台 + Clear() + { + } +} diff --git a/src/Nest/Core/OptimizeWorker.worker.ts b/src/Nest/Core/OptimizeWorker.worker.ts new file mode 100644 index 0000000..da76cb5 --- /dev/null +++ b/src/Nest/Core/OptimizeWorker.worker.ts @@ -0,0 +1,27 @@ +const ctx: Worker = self as any; +import { InitClipperCpp } from "../Common/ClipperCpp"; +import { NestFiler } from "../Common/Filer"; +import { NestDatabase } from "./NestDatabase"; +import { OptimizeMachine } from "./OptimizeMachine"; + +ctx.addEventListener("message", async (event) => +{ + await InitClipperCpp(); + let f = new NestFiler(event.data); + let db = new NestDatabase; + db.ReadFile(f); + + let m = new OptimizeMachine; + m.Bin = db.Bin; + m.PutParts(db.Parts); + + m.callBack = async (inv) => + { + let f = new NestFiler(); + inv.WriteFile(f); + ctx.postMessage(f._datas); + }; + await m.Start(); +}); + +export default {} as typeof Worker & (new () => Worker); diff --git a/src/Nest/Core/Part.ts b/src/Nest/Core/Part.ts new file mode 100644 index 0000000..aef2724 --- /dev/null +++ b/src/Nest/Core/Part.ts @@ -0,0 +1,178 @@ +import { NestFiler } from "../Common/Filer"; +import { PartState } from "./PartState"; +import { Path } from "./Path"; +import { PathGeneratorSingle } from "./PathGenerator"; +import { Point } from "../Common/Point"; +import { RandomIndex } from "../Common/Random"; +import { Vector2 } from "../Common/Vector2"; + +/** + * 零件类 + * 零件类可以绑定数据,也存在位置和旋转状态的信息 + * + * 初始化零件: + * 传入零件的轮廓,刀半径,包围容器(或者为空?) + * 初始化用于放置的轮廓。将轮廓首点移动到0点,记录移动的点P。 + * + * 零件放置位置: + * 表示零件轮廓首点的位置。 + * + * 零件的旋转: + * 表示零件轮廓按照首点(0)旋转。 + * + * 还原零件的放置状态: + * 同样将零件移动到0点 + * 同样将零件旋转 + * 同样将零件移动到指定的位置 + * 零件可能处于容器中,变换到容器坐标系 + * + */ +export class Part +{ + Id: number;//用于确定Part的唯一性,并且有助于在其他Work中还原 + + //下面数据只用于还原零件的显示状态,在优化中无作用 + UserData: T; //应该也是可序列化的实体 + PlaceCS: Matrix;//放置矩阵 Matrix4 + Parent: Part; + + Holes: PartState[] = []; + //零件的不同旋转状态,这个数组会在所有的状态间共享,以便快速切换状态 + RotatedStates: PartState[] = []; + PlacePosition: Point; //放置位置(相对于容器的位置) + StateIndex = 0; //放置状态 + + get State(): PartState //零件当前的状态 + { + return this.RotatedStates[this.StateIndex]; + } + + //初始化零件的各个状态,按360度旋转个数 + Init(path: Path, bin: Path, rotateCount = 4): this + { + let rotations: number[] = []; + let a = 2 * Math.PI / rotateCount; + for (let i = 0; i < rotateCount; i++) + { + rotations.push(a * i); + } + this.Init2(path, bin, rotations); + return this; + } + + //初始化零件的各个状态,按旋转角度表 + Init2(path: Path, bin: Path, rotations: number[] = []): this + { + let pathP = path.OrigionMinPoint; + let path_0 = PathGeneratorSingle.Allocate(path); + let pathSet = new Set(); + + //初始化零件的状态集合 + for (let pa of rotations) + { + let partState = new PartState(); + partState.Rotation = pa; + if (pa === 0) + { + partState.Contour = path_0; + partState.OrigionMinPoint = pathP; + } + else + { + let path_r = new Path(path.Points, pa); + partState.Contour = PathGeneratorSingle.Allocate(path_r); + partState.Contour.Area = path_0.Area; + //避免重复的Path进入State + if (pathSet.has(partState.Contour)) continue; + let p0 = path_r.OrigionMinPoint; + let c = Math.cos(-pa); + let s = Math.sin(-pa); + let x1 = p0.x * c - p0.y * s; + let y1 = p0.x * s + p0.y * c; + partState.OrigionMinPoint = new Vector2(pathP.x + x1, pathP.y + y1); + if (partState.Contour.Origion === undefined) + { + partState.Contour.Origion = path_0; + partState.Contour.OrigionMinPoint = p0; + } + } + //记录已有Path + pathSet.add(partState.Contour); + //必须能放置 + if (bin.GetInsideNFP(partState.Contour)) + { + this.RotatedStates.push(partState); + PathGeneratorSingle.RegisterId(partState.Contour); + } + } + + //为了复用NFP,不管第0个Path是否可用,都注册它. + if (this.RotatedStates.length > 4) + PathGeneratorSingle.RegisterId(path_0); + return this; + } + + AppendHole(path: Path) + { + let hole = new PartState(); + hole.Contour = PathGeneratorSingle.Allocate(path); + PathGeneratorSingle.RegisterId(hole.Contour); + hole.OrigionMinPoint = path.OrigionMinPoint; + hole.Rotation = 0; + this.Holes.push(hole); + } + + //浅克隆 + Clone() + { + let part = new Part(); + part.Id = this.Id; + part.UserData = this.UserData; + part.RotatedStates = this.RotatedStates; + part.StateIndex = this.StateIndex; + part.Holes = this.Holes; + return part; + } + + //旋转起来,改变自身旋转状态(变异) + Mutate(): this + { + this.StateIndex = RandomIndex(this.RotatedStates.length, this.StateIndex); + return this; + } + + //#region -------------------------File------------------------- + ReadFile(file: NestFiler) + { + this.Id = file.Read(); + let count = file.Read() as number; + this.RotatedStates = []; + for (let i = 0; i < count; i++) + { + let state = new PartState(); + state.ReadFile(file); + this.RotatedStates.push(state); + } + + count = file.Read(); + this.Holes = []; + for (let i = 0; i < count; i++) + { + let state = new PartState(); + state.ReadFile(file); + this.Holes.push(state); + } + } + WriteFile(file: NestFiler) + { + file.Write(this.Id); + file.Write(this.RotatedStates.length); + for (let state of this.RotatedStates) + state.WriteFile(file); + + file.Write(this.Holes.length); + for (let hole of this.Holes) + hole.WriteFile(file); + } + //#endregion +} diff --git a/src/Nest/Core/PartState.ts b/src/Nest/Core/PartState.ts new file mode 100644 index 0000000..6a76c0e --- /dev/null +++ b/src/Nest/Core/PartState.ts @@ -0,0 +1,35 @@ +import { Path } from "./Path"; +import { Point } from "../Common/Point"; +import { PathGeneratorSingle } from "./PathGenerator"; +import { NestFiler } from "../Common/Filer"; + +/** + * 用于存放零件旋转后的状态 + * 记录了用于放置时的轮廓。该轮廓总是首点等于0,便于放置时的计算。 + */ +export class PartState +{ + Rotation: number; + OrigionMinPoint: Point; + Contour: Path;//轮廓 + + //#region -------------------------File------------------------- + ReadFile(file: NestFiler) + { + this.Rotation = file.Read(); + this.OrigionMinPoint = file.Read(); + + let index = file.Read() as number; + this.Contour = PathGeneratorSingle.paths[index]; + + if (!this.Contour) + console.log(index); + } + WriteFile(file: NestFiler) + { + file.Write(this.Rotation); + file.Write(this.OrigionMinPoint); + file.Write(this.Contour.Id); + } + //#endregion +} diff --git a/src/Nest/Core/Path.ts b/src/Nest/Core/Path.ts new file mode 100644 index 0000000..9963764 --- /dev/null +++ b/src/Nest/Core/Path.ts @@ -0,0 +1,345 @@ +import { Box2 } from "../Common/Box2"; +import { clipperCpp } from "../Common/ClipperCpp"; +import { NestFiler } from "../Common/Filer"; +import { Point } from "../Common/Point"; +import { equaln } from "../Common/Util"; +import { Vector2 } from "../Common/Vector2"; + +/** + * 轮廓路径类 + * 可以求NFP,和保存NFPCahce + * 因为NFP结果是按照最低点移动的,所以将点旋转后,按照盒子将点移动到0点. + */ +export class Path +{ + Id: number; + Points: Point[]; + OutsideNFPCache: { [key: number]: Point[][]; } = {}; + InsideNFPCache: { [key: number]: Point[][]; } = {}; + + constructor(origionPoints?: Point[], rotation: number = 0) + { + if (origionPoints) + this.Init(origionPoints, rotation); + } + + Origion: Path; + //点表在旋转后的原始最小点.使用这个点将轮廓移动到0点 + OrigionMinPoint: Vector2; + Rotation: number; + + Size: Vector2;//序列化 + Init(origionPoints: Point[], rotation: number) + { + this.Rotation = rotation; + if (rotation === 0) + this.Points = origionPoints.map(p => { return { ...p }; }); + else + { + let c = Math.cos(rotation); + let s = Math.sin(rotation); + + let npts: Point[] = []; + for (let p of origionPoints) + { + let x = p.x; + let y = p.y; + const x1 = x * c - y * s; + const y1 = x * s + y * c; + npts.push({ x: x1, y: y1 }); + } + this.Points = npts; + } + + let box = new Box2(); + let v2 = new Vector2(); + for (let p of this.Points) + { + v2.x = p.x; + v2.y = p.y; + box.expandByPoint(v2); + } + + this.OrigionMinPoint = box.min; + this.Size = box.max.sub(box.min); + + for (let p of this.Points) + { + p.x -= box.min.x; + p.y -= box.min.y; + } + } + + GetNFPs(path: Path, outside: boolean): Point[][] + { + // 寻找内轮廓时,面积应该比本path小,这个判断移交给使用者自己判断 + // if (!outside && this.Area < path.Area) return []; + let nfps = clipperCpp.lib.minkowskiSumPath(this.BigIntPoints, path.MirrorPoints, true); + nfps = nfps.filter((nfp) => + { + let area = Area(nfp); + if (area > 1) return outside;//第一个不一定是外轮廓,但是面积为正时肯定为外轮廓 + if (Math.abs(area) < 10) return false;//应该不用在移除这个了 + + let { x, y } = nfp[0]; + if (outside) + { + if (this.Area > path.Area) + { + let p = { x: path.InPoint.x + x, y: path.InPoint.y + y }; + if (p.x < 0 || p.y < 0 || p.x > this.BigSize.x || p.y > this.BigSize.y) + return true; + let dir = clipperCpp.lib.pointInPolygon(p, this.BigIntPoints); + return dir === 0; + } + else + { + let p = { x: this.InPoint.x - x, y: this.InPoint.y - y }; + if (p.x < 0 || p.y < 0 || p.x > path.BigSize.x || p.y > path.BigSize.y) + return true; + let dir = clipperCpp.lib.pointInPolygon(p, path.BigIntPoints); + return dir === 0; + } + } + else + { + let p = { x: path.InPoint.x + x, y: path.InPoint.y + y }; + if (p.x < 0 || p.y < 0 || p.x > this.BigSize.x || p.y > this.BigSize.y) + return false; + let dir = clipperCpp.lib.pointInPolygon(p, this.BigIntPoints); + return dir === 1; + } + }); + return nfps; + } + + GetOutsideNFP(path: Path): Point[][] + { + let nfps = this.OutsideNFPCache[path.Id]; + if (nfps) return nfps; + + if (this.IsRect && path.IsRect) + { + let [ax, ay] = [this.Size.x * 1e4, this.Size.y * 1e4]; + let [bx, by] = [path.Size.x * 1e4, path.Size.y * 1e4]; + nfps = [[ + { x: -bx, y: -by }, + { x: ax, y: -by }, + { x: ax, y: ay }, + { x: -bx, y: ay }, + ]]; + } + else + nfps = this.GetNFPs(path, true); + this.OutsideNFPCache[path.Id] = nfps; + //虽然有这种神奇的特性,但是好像并不会提高性能。 + // path.OutsideNFPCache[this.id] = (this, nfps.map(nfp => + // { + // return nfp.map(p => + // { + // return { x: -p.x, y: -p.y }; + // }); + // })); + return nfps; + } + GetInsideNFP(path: Path): Point[][] + { + if (path.Area > this.Area) return; + let nfp = this.InsideNFPCache[path.Id]; + if (nfp) return nfp; + + let nfps: Point[][]; + if (this.IsRect) + { + let [ax, ay] = [this.Size.x * 1e4, this.Size.y * 1e4]; + let [bx, by] = [path.Size.x * 1e4, path.Size.y * 1e4]; + + if (ax === bx) ax += 1; + if (ay === by) ay += 1; + + if (bx > ax || by > ay) + return; + nfps = [[ + { x: 0, y: 0 }, + { x: ax - bx, y: 0 }, + { x: ax - bx, y: ay - by }, + { x: 0, y: ay - by } + ]]; + } + else + nfps = this.GetNFPs(path, false); + + if (path.Id !== undefined) + this.InsideNFPCache[path.Id] = nfps; + return nfps; + } + + private _InPoint: Point; + + /** + * 用这个点来检测是否在Path内部 + */ + private get InPoint() + { + if (this._InPoint) return this._InPoint; + let mp = { x: (this.Points[0].x + this.Points[1].x) / 2, y: (this.Points[0].y + this.Points[1].y) / 2 }; + let normal = new Vector2(this.Points[1].x - this.Points[0].x, this.Points[1].y - this.Points[0].y).normalize(); + // [normal.x, normal.y] = [normal.y, -normal.x]; + mp.x -= normal.y; + mp.y += normal.x; + + mp.x *= 1e4; + mp.y *= 1e4; + this._InPoint = mp; + return mp; + } + + protected _BigIntPoints: Point[]; + get BigIntPoints() + { + if (this._BigIntPoints) return this._BigIntPoints; + this._BigIntPoints = this.Points.map(p => + { + return { + x: Math.round(p.x * 1e4), + y: Math.round(p.y * 1e4), + }; + }); + return this._BigIntPoints; + } + + private _BigSize: Vector2; + get BigSize() + { + if (this._BigSize) return this._BigSize; + this._BigSize = new Vector2(this.Size.x * 1e4, this.Size.y * 1e4); + return this._BigSize; + } + + protected _MirrorPoints: Point[]; + get MirrorPoints() + { + if (!this._MirrorPoints) + this._MirrorPoints = this.BigIntPoints.map(p => + { + return { x: -p.x, y: -p.y }; + }); + + return this._MirrorPoints; + } + + protected _BoundingBox: Box2; + get BoundingBox() + { + if (!this._BoundingBox) + this._BoundingBox = new Box2(new Vector2, this.Size); + return this._BoundingBox; + } + + protected _Area: number; + get Area() + { + if (this._Area === undefined) + this._Area = Area(this.Points); + return this._Area; + } + set Area(a: number) + { + this._Area = a; + } + + private _IsRect: boolean; + get IsRect() + { + if (this._IsRect === undefined) + { + let s = this.BoundingBox.getSize(new Vector2); + this._IsRect = equaln(this.Area, s.x * s.y, 1); + } + return this._IsRect; + } + + ReadFile(file: NestFiler): void + { + let ver = file.Read(); + this.Id = file.Read(); + let arr = file.Read(); + this.Points = []; + for (let i = 0; i < arr.length; i += 2) + { + let p = { x: arr[i], y: arr[i + 1] }; + this.Points.push(p); + } + + this.Size = new Vector2(file.Read(), file.Read()); + this._Area = file.Read(); + let id = file.Read(); + if (id !== -1) + { + this.Origion = id; + this.Rotation = file.Read(); + this.OrigionMinPoint = new Vector2(file.Read(), file.Read()); + } + } + WriteFile(file: NestFiler): void + { + file.Write(1);//ver + file.Write(this.Id); + let arr: number[] = []; + for (let p of this.Points) + arr.push(p.x, p.y); + file.Write(arr); + + file.Write(this.Size.x); + file.Write(this.Size.y); + file.Write(this._Area); + if (this.Origion && this.Origion.Id) + { + //如果有原始的id,则传递它,以便后续进行NFP复用. + file.Write(this.Origion.Id); + file.Write(this.Rotation); + file.Write(this.OrigionMinPoint.x); + file.Write(this.OrigionMinPoint.y); + } + else + file.Write(-1); + } +} + + +//点表面积 +export function Area(pts: Point[]): number +{ + let cnt = pts.length; + if (cnt < 3) + return 0; + let a = 0; + for (let i = 0, j = cnt - 1; i < cnt; ++i) + { + a += (pts[j].x + pts[i].x) * (pts[j].y - pts[i].y); + j = i; + } + return -a * 0.5; +} + +/** + * 平移点表,返回新点表 + */ +export function TranslatePath(pts: Point[], p: Point): Point[] +{ + return pts.map(px => + { + return { x: p.x + px.x, y: p.y + px.y }; + }); +} + +//缩放点表,返回原始点表 +export function PathScale(pts: Point[], scale: number): Point[] +{ + for (let p of pts) + { + p.x *= scale; + p.y *= scale; + } + return pts; +} diff --git a/src/Nest/Core/PathGenerator.ts b/src/Nest/Core/PathGenerator.ts new file mode 100644 index 0000000..861f86e --- /dev/null +++ b/src/Nest/Core/PathGenerator.ts @@ -0,0 +1,85 @@ +import { Path } from "./Path"; +import { equaln, FixIndex } from "../Common/Util"; + +/** + * 轮廓路径构造器 + * 传递一组简化后的点表过来,如果已经有同样的点表时,返回已经生产的Path,避免重复产生Path。 + * 使用相同的PATH有复用路径缓存。 + * + * 每次进行优化时,必须清理构造器,保证Path生成是对本次优化唯一。 + */ +class PathGenerator +{ + paths: Path[] = []; + pathAreaMap: { [key: string]: Path[]; } = {}; + + //缓存命中次数 + cacheCount = 0; + /** + * 如果存在同样的轮廓,则返回已经构造的轮廓, + * 如果没有,则返回自身,并且注册它。 + * 如果id没有被注册,那么证明它无法放置在bin中 + */ + Allocate(path: Path): Path + { + let area = path.Area.toFixed(0); + let paths = this.pathAreaMap[area]; + if (paths) + { + for (let ps of paths) + { + if (EqualPath(ps, path)) + { + this.cacheCount++; + return ps; + } + } + paths.push(path); + } + else + this.pathAreaMap[area] = [path]; + return path; + } + + RegisterId(path: Path) + { + if (path.Id === undefined) + { + path.Id = this.paths.length; + this.paths.push(path); + } + } + + Clear() + { + this.paths.length = 0; + this.pathAreaMap = {}; + this.cacheCount = 0; + } +} + +/** + * 两路径相等,点表个数相等且每个点都相似 + */ +function EqualPath(path1: Path, path2: Path): boolean +{ + if (path1.Points.length !== path2.Points.length) return false; + + let p0 = path1.Points[0]; + let p2Index = path2.Points.findIndex(p => + { + return equaln(p.x, p0.x, 1e-3) && equaln(p.y, p0.y, 1e-3); + }); + + for (let i = 0; i < path1.Points.length; i++) + { + let p1 = path1.Points[i]; + let p2 = path2.Points[FixIndex(p2Index + i, path2.Points)]; + + if (!equaln(p1.x, p2.x, 1e-4) || !equaln(p1.y, p2.y, 1e-4)) + return false; + } + return true; +} + +export let PathGeneratorSingle = new PathGenerator; diff --git a/src/Nest/Core/PlaceType.ts b/src/Nest/Core/PlaceType.ts new file mode 100644 index 0000000..dc43517 --- /dev/null +++ b/src/Nest/Core/PlaceType.ts @@ -0,0 +1,7 @@ + +export enum PlaceType +{ + Hull = 0,//凸包模式 (凸包面积) + Box = 1, //盒子模式 (长乘以宽) + Gravity = 2,//重力模式(重力) +} diff --git a/src/assets/logo.png b/src/assets/logo.png deleted file mode 100644 index f3d2503fc2a44b5053b0837ebea6e87a2d339a43..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6849 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 -
-

{{ msg }}

-

- For a guide and recipes on how to configure / customize this project,
- check out the - vue-cli documentation. -

-

Installed CLI Plugins

- -

Essential Links

- -

Ecosystem

- -
- - - - - - diff --git a/src/components/SelectFile.vue b/src/components/SelectFile.vue new file mode 100644 index 0000000..a7e57eb --- /dev/null +++ b/src/components/SelectFile.vue @@ -0,0 +1,36 @@ + + diff --git a/src/main.ts b/src/main.ts index a3fd06b..4eacfb7 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,8 +1,44 @@ -import Vue from "vue"; -import App from "./App.vue"; +import Vue from 'vue'; +// import dayjs from 'dayjs'; +import App from './App.vue'; +import ElementUI from 'element-ui'; +import 'element-ui/lib/theme-chalk/index.css'; +import 'element-ui/lib/theme-chalk/display.css'; +// import 'element-ui/lib/theme-default/index.css' +// import './icons'; // icon + +// import '@/styles/index.scss'; // global css +// import '@/styles/custom.scss'; // custom css + +// import VueRouter from 'vue-router'; +// import store from './store'; +// import Vuex from 'vuex'; + +// import router from './routes'; + +// import './permission'; // permission control +// import 'dayjs/locale/zh-cn'; // load on demand +// import GlobalConfig from "./config"; +// GlobalConfig.event.saveAllConfig = ()=>{}; + +// console.log(GlobalConfig.event) + +// dayjs.locale('zh-cn'); + +// import('element-ui').then(ElementUI=>{ + Vue.use(ElementUI, { size: 'small' }); + // Vue.use(VueRouter); + // Vue.use(Vuex); + + + new Vue({ + // el: '#app', + // template: '', + // router, + // store, + // components: { App } + render: (h: any) => h(App), + }).$mount('#app'); +// }) -Vue.config.productionTip = false; -new Vue({ - render: h => h(App) -}).$mount("#app"); diff --git a/tests/unit/example.spec.ts b/tests/unit/example.spec.ts deleted file mode 100644 index a846fbd..0000000 --- a/tests/unit/example.spec.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { shallowMount } from "@vue/test-utils"; -import HelloWorld from "@/components/HelloWorld.vue"; - -describe("HelloWorld.vue", () => { - it("renders props.msg when passed", () => { - const msg = "new message"; - const wrapper = shallowMount(HelloWorld, { - propsData: { msg } - }); - expect(wrapper.text()).toMatch(msg); - }); -}); diff --git a/tsconfig.json b/tsconfig.json index 17eb562..341457c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "target": "esnext", "module": "esnext", - "strict": true, + // "strict": true, "jsx": "preserve", "importHelpers": true, "moduleResolution": "node", @@ -10,21 +10,11 @@ "allowSyntheticDefaultImports": true, "sourceMap": true, "baseUrl": ".", - "types": [ - "webpack-env", - "jest" - ], + "types": ["node","webpack-env", "jest"], "paths": { - "@/*": [ - "src/*" - ] + "@/*": ["src/*"] }, - "lib": [ - "esnext", - "dom", - "dom.iterable", - "scripthost" - ] + "lib": ["esnext", "dom", "dom.iterable", "scripthost"] }, "include": [ "src/**/*.ts", @@ -33,7 +23,5 @@ "tests/**/*.ts", "tests/**/*.tsx" ], - "exclude": [ - "node_modules" - ] + "exclude": ["node_modules"] } diff --git a/vue.config.js b/vue.config.js new file mode 100644 index 0000000..3caf62e --- /dev/null +++ b/vue.config.js @@ -0,0 +1,44 @@ +// vue.config.js +const path = require("path"); +function resolve(dir) { + return path.join(__dirname, dir); +} +module.exports = { + // publicPath: '', + runtimeCompiler: true, + productionSourceMap: false, + configureWebpack: { + devtool: "source-map", + output: { + globalObject: "this", + }, + }, + chainWebpack(config) { + let tsRule = config.module + .rule("ts").uses; + config.module + .rule("worker") + .test(/\.worker\.ts$/i) + .use("worker-loader") + .loader("worker-loader").end() + .use("ts-loader") + .loader("ts-loader").options({ + transpileOnly: true, + happyPackMode: false + }).end(); + config.module + .rule("fonts") + .use("url-loader") + .loader("url-loader") + .options({ + limit: 4096, + fallback: { + loader: "file-loader", + options: { + name: "fonts/[name].[contenthash].[ext]", + }, + }, + }) + .end(); + }, +};