diff --git a/asp-review-app/.gitignore b/asp-review-app/.gitignore index 048c8dd..a2424f7 100644 --- a/asp-review-app/.gitignore +++ b/asp-review-app/.gitignore @@ -22,3 +22,5 @@ npm-debug.log* yarn-debug.log* yarn-error.log* **/node_modules +server/public/ +**/computed/ \ No newline at end of file diff --git a/asp-review-app/server/package-lock.json b/asp-review-app/server/package-lock.json index 5d626cf..686b9b1 100644 --- a/asp-review-app/server/package-lock.json +++ b/asp-review-app/server/package-lock.json @@ -15,6 +15,7 @@ "compression": "^1.7.4", "concurrently": "^8.0.1", "cors": "^2.8.5", + "decompress": "^4.2.1", "express": "^4.18.2", "express-cross": "^1.0.0", "express-fileupload": "^1.4.0", @@ -25,6 +26,7 @@ "multer": "^1.4.5-lts.1", "node-stream-zip": "^1.15.0", "nodemon": "^2.0.22", + "shelljs": "^0.8.5", "ts-node": "^10.9.1" }, "devDependencies": { @@ -350,6 +352,25 @@ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/basic-auth": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", @@ -374,6 +395,15 @@ "node": ">=8" } }, + "node_modules/bl": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.3.tgz", + "integrity": "sha512-pvcNpa0UU69UT341rO6AYy4FVAIkUHuZXRIWbq+zHnsVcRzDDjIAhGuuYoi0d//cwIwtt4pkpKycWEfjdV+vww==", + "dependencies": { + "readable-stream": "^2.3.5", + "safe-buffer": "^5.1.1" + } + }, "node_modules/body-parser": { "version": "1.20.2", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", @@ -426,6 +456,56 @@ "node": ">=14.20.1" } }, + "node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "node_modules/buffer-alloc": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz", + "integrity": "sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==", + "dependencies": { + "buffer-alloc-unsafe": "^1.1.0", + "buffer-fill": "^1.0.0" + } + }, + "node_modules/buffer-alloc-unsafe": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz", + "integrity": "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==" + }, + "node_modules/buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==", + "engines": { + "node": "*" + } + }, + "node_modules/buffer-fill": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz", + "integrity": "sha512-T7zexNBwiiaCOGDg9xNX9PBmjrubblRkENuptryuI64URkXDFum9il/JGL8Lm8wYfAXpredVXXZz7eMHilimiQ==" + }, "node_modules/buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", @@ -577,6 +657,11 @@ "node": ">= 0.8" } }, + "node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + }, "node_modules/compressible": { "version": "2.0.18", "resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.18.tgz", @@ -762,6 +847,95 @@ "ms": "2.0.0" } }, + "node_modules/decompress": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/decompress/-/decompress-4.2.1.tgz", + "integrity": "sha512-e48kc2IjU+2Zw8cTb6VZcJQ3lgVbS4uuB1TfCHbiZIP/haNXm+SVyhu+87jts5/3ROpd82GSVCoNs/z8l4ZOaQ==", + "dependencies": { + "decompress-tar": "^4.0.0", + "decompress-tarbz2": "^4.0.0", + "decompress-targz": "^4.0.0", + "decompress-unzip": "^4.0.1", + "graceful-fs": "^4.1.10", + "make-dir": "^1.0.0", + "pify": "^2.3.0", + "strip-dirs": "^2.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/decompress-tar": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/decompress-tar/-/decompress-tar-4.1.1.tgz", + "integrity": "sha512-JdJMaCrGpB5fESVyxwpCx4Jdj2AagLmv3y58Qy4GE6HMVjWz1FeVQk1Ct4Kye7PftcdOo/7U7UKzYBJgqnGeUQ==", + "dependencies": { + "file-type": "^5.2.0", + "is-stream": "^1.1.0", + "tar-stream": "^1.5.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/decompress-tarbz2": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/decompress-tarbz2/-/decompress-tarbz2-4.1.1.tgz", + "integrity": "sha512-s88xLzf1r81ICXLAVQVzaN6ZmX4A6U4z2nMbOwobxkLoIIfjVMBg7TeguTUXkKeXni795B6y5rnvDw7rxhAq9A==", + "dependencies": { + "decompress-tar": "^4.1.0", + "file-type": "^6.1.0", + "is-stream": "^1.1.0", + "seek-bzip": "^1.0.5", + "unbzip2-stream": "^1.0.9" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/decompress-tarbz2/node_modules/file-type": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-6.2.0.tgz", + "integrity": "sha512-YPcTBDV+2Tm0VqjybVd32MHdlEGAtuxS3VAYsumFokDSMG+ROT5wawGlnHDoz7bfMcMDt9hxuXvXwoKUx2fkOg==", + "engines": { + "node": ">=4" + } + }, + "node_modules/decompress-targz": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/decompress-targz/-/decompress-targz-4.1.1.tgz", + "integrity": "sha512-4z81Znfr6chWnRDNfFNqLwPvm4db3WuZkqV+UgXQzSngG3CEKdBkw5jrv3axjjL96glyiiKjsxJG3X6WBZwX3w==", + "dependencies": { + "decompress-tar": "^4.1.1", + "file-type": "^5.2.0", + "is-stream": "^1.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/decompress-unzip": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/decompress-unzip/-/decompress-unzip-4.0.1.tgz", + "integrity": "sha512-1fqeluvxgnn86MOh66u8FjbtJpAFv5wgCT9Iw8rcBqQcCo5tO8eiJw7NNTrvt9n4CRBVq7CstiS922oPgyGLrw==", + "dependencies": { + "file-type": "^3.8.0", + "get-stream": "^2.2.0", + "pify": "^2.3.0", + "yauzl": "^2.4.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/decompress-unzip/node_modules/file-type": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", + "integrity": "sha512-RLoqTXE8/vPmMuTI88DAzhMYC99I8BWv7zYP4A1puo5HIjEJ5EX48ighy4ZyKMG9EDXxBgW6e++cn7d1xuFghA==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -813,6 +987,14 @@ "node": ">= 0.8" } }, + "node_modules/end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dependencies": { + "once": "^1.4.0" + } + }, "node_modules/escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", @@ -928,6 +1110,22 @@ "node": ">= 0.8" } }, + "node_modules/fd-slicer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", + "integrity": "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==", + "dependencies": { + "pend": "~1.2.0" + } + }, + "node_modules/file-type": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-5.2.0.tgz", + "integrity": "sha512-Iq1nJ6D2+yIO4c8HHg4fyVb8mAJieo1Oloy1mLLaB2PvezNedhBVm+QU7g0qM42aiMbRXTxKKwGD17rjKNJYVQ==", + "engines": { + "node": ">=4" + } + }, "node_modules/fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -993,6 +1191,16 @@ "node": ">= 0.6" } }, + "node_modules/fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" + }, "node_modules/fsevents": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", @@ -1032,6 +1240,37 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/get-stream": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz", + "integrity": "sha512-AUGhbbemXxrZJRD5cDvKtQxLuYaIbNtDTK8YqupCI393Q2KSTreEsLUN3ZxAWFGiKTzL6nKuzfcIvieflUX9qA==", + "dependencies": { + "object-assign": "^4.0.1", + "pinkie-promise": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/glob-parent": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", @@ -1043,6 +1282,11 @@ "node": ">= 6" } }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" + }, "node_modules/has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -1099,16 +1343,52 @@ "node": ">=0.10.0" } }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/ignore-by-default": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==" }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, + "node_modules/interpret": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz", + "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==", + "engines": { + "node": ">= 0.10" + } + }, "node_modules/ip": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz", @@ -1134,6 +1414,17 @@ "node": ">=8" } }, + "node_modules/is-core-module": { + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.12.1.tgz", + "integrity": "sha512-Q4ZuBAe2FUsKtyQJoQHlvP8OvBERxO3jEmy1I7hcRXcJBGGHFh/aJBswbXuS9sgrDH2QUO8ilkwNPHvHMd8clg==", + "dependencies": { + "has": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -1161,6 +1452,11 @@ "node": ">=0.10.0" } }, + "node_modules/is-natural-number": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-natural-number/-/is-natural-number-4.0.1.tgz", + "integrity": "sha512-Y4LTamMe0DDQIIAlaer9eKebAlDSV6huy+TWhJVPlzZh2o4tRP5SQWFlLn5N0To4mDD22/qdOq+veo1cSISLgQ==" + }, "node_modules/is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", @@ -1169,6 +1465,14 @@ "node": ">=0.12.0" } }, + "node_modules/is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -1193,6 +1497,25 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, + "node_modules/make-dir": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", + "integrity": "sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ==", + "dependencies": { + "pify": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/make-dir/node_modules/pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg==", + "engines": { + "node": ">=4" + } + }, "node_modules/make-error": { "version": "1.3.6", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", @@ -1566,6 +1889,14 @@ "node": ">= 0.8" } }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dependencies": { + "wrappy": "1" + } + }, "node_modules/parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -1574,11 +1905,29 @@ "node": ">= 0.8" } }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" + }, "node_modules/path-to-regexp": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" }, + "node_modules/pend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", + "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==" + }, "node_modules/picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", @@ -1590,6 +1939,33 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha512-MnUuEycAemtSaeFSjXKW/aroV7akBbY+Sv+RkyqFjgAe73F+MR0TBWKBRDkmfWq/HiFmdavfZ1G7h4SPZXaCSg==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha512-0Gni6D4UcLTbv9c57DfxDGdr41XfgUjqWZu492f0cIGr16zDU06BWP/RAEvOuo7CQ0CNjHaLlM59YJJFm3NWlw==", + "dependencies": { + "pinkie": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", @@ -1687,6 +2063,17 @@ "node": ">=8.10.0" } }, + "node_modules/rechoir": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", + "integrity": "sha512-HFM8rkZ+i3zrV+4LQjwQ0W+ez98pApMGM3HUrN04j3CqzPOzl9nmP15Y8YXNm8QHGv/eacOVEjqhmWpkRV0NAw==", + "dependencies": { + "resolve": "^1.1.6" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/reflect-metadata": { "version": "0.1.13", "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz", @@ -1706,6 +2093,22 @@ "node": ">=0.10.0" } }, + "node_modules/resolve": { + "version": "1.22.2", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.2.tgz", + "integrity": "sha512-Sb+mjNHOULsBv818T40qSPeRiuWLyaGMa5ewydRLFimneixmVy2zdivRl+AF6jaYPC8ERxGDmFSiqui6SfPd+g==", + "dependencies": { + "is-core-module": "^2.11.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/rxjs": { "version": "7.8.1", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", @@ -1751,6 +2154,18 @@ "node": ">=6" } }, + "node_modules/seek-bzip": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/seek-bzip/-/seek-bzip-1.0.6.tgz", + "integrity": "sha512-e1QtP3YL5tWww8uKaOCQ18UxIT2laNBXHjV/S2WYCiK4udiv8lkG89KRIoCjUagnAmCBurjF4zEVX2ByBbnCjQ==", + "dependencies": { + "commander": "^2.8.1" + }, + "bin": { + "seek-bunzip": "bin/seek-bunzip", + "seek-table": "bin/seek-bzip-table" + } + }, "node_modules/semver": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", @@ -1814,6 +2229,22 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/shelljs": { + "version": "0.8.5", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.5.tgz", + "integrity": "sha512-TiwcRcrkhHvbrZbnRcFYMLl30Dfov3HKqzp5tO5b4pt6G/SezKcYhmDg15zXVBswHmctSAQKznqNW2LO5tTDow==", + "dependencies": { + "glob": "^7.0.0", + "interpret": "^1.0.0", + "rechoir": "^0.6.2" + }, + "bin": { + "shjs": "bin/shjs" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/side-channel": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", @@ -1944,6 +2375,14 @@ "node": ">=8" } }, + "node_modules/strip-dirs": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/strip-dirs/-/strip-dirs-2.1.0.tgz", + "integrity": "sha512-JOCxOeKLm2CAS73y/U4ZeZPTkE+gNVCzKt7Eox84Iej1LT/2pTWYpZKJuxwQpvX1LiZb1xokNR7RLfuBAa7T3g==", + "dependencies": { + "is-natural-number": "^4.0.1" + } + }, "node_modules/supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -1955,6 +2394,44 @@ "node": ">=4" } }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/tar-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.6.2.tgz", + "integrity": "sha512-rzS0heiNf8Xn7/mpdSVVSMAWAoy9bfb1WOTYC78Z0UQKeKa/CWS8FOq0lKGNa8DWKAn9gxjCvMLYc5PGXYlK2A==", + "dependencies": { + "bl": "^1.0.0", + "buffer-alloc": "^1.2.0", + "end-of-stream": "^1.0.0", + "fs-constants": "^1.0.0", + "readable-stream": "^2.3.0", + "to-buffer": "^1.1.1", + "xtend": "^4.0.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==" + }, + "node_modules/to-buffer": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.1.1.tgz", + "integrity": "sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg==" + }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -2081,6 +2558,15 @@ "node": ">=4.2.0" } }, + "node_modules/unbzip2-stream": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.4.3.tgz", + "integrity": "sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==", + "dependencies": { + "buffer": "^5.2.1", + "through": "^2.3.8" + } + }, "node_modules/undefsafe": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", @@ -2166,6 +2652,11 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, "node_modules/xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", @@ -2207,6 +2698,15 @@ "node": ">=12" } }, + "node_modules/yauzl": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==", + "dependencies": { + "buffer-crc32": "~0.2.3", + "fd-slicer": "~1.1.0" + } + }, "node_modules/yn": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", diff --git a/asp-review-app/server/package.json b/asp-review-app/server/package.json index 48cfdf5..9f67de8 100644 --- a/asp-review-app/server/package.json +++ b/asp-review-app/server/package.json @@ -6,7 +6,7 @@ "type": "module", "scripts": { "build": "npx tsc", - "start": "node dist/index.js", + "start": "npx tsc && node --experimental-specifier-resolution=node dist/server.js", "dev": "nodemon --exec ts-node --esm --transpileOnly ./src/server.ts" }, "keywords": [], @@ -28,6 +28,7 @@ "compression": "^1.7.4", "concurrently": "^8.0.1", "cors": "^2.8.5", + "decompress": "^4.2.1", "express": "^4.18.2", "express-cross": "^1.0.0", "express-fileupload": "^1.4.0", @@ -38,6 +39,7 @@ "multer": "^1.4.5-lts.1", "node-stream-zip": "^1.15.0", "nodemon": "^2.0.22", + "shelljs": "^0.8.5", "ts-node": "^10.9.1" } } diff --git a/asp-review-app/server/src/app.ts b/asp-review-app/server/src/app.ts index 9d8dfda..cf8e430 100644 --- a/asp-review-app/server/src/app.ts +++ b/asp-review-app/server/src/app.ts @@ -17,8 +17,11 @@ const corsOptions = { }; export class App { public app: express.Application; + public port: string | number; + public env: string; + constructor(routes: Routes[], port) { this.app = express(); this.port = port; @@ -50,7 +53,6 @@ export class App { this.app.use(express.urlencoded({ extended: true })); this.app.use(bodyParser.json()); this.app.use(bodyParser.urlencoded({ extended: true })); - console.log(dirname + '/public/') this.app.use(express.static(dirname + '/public/')); this.app.use(fileUpload({ createParentPath: true @@ -62,8 +64,8 @@ export class App { this.app.use("/", route.router); }); } + loadAppDependencies() { - locator(new DevEnv()); } } \ No newline at end of file diff --git a/asp-review-app/server/src/core/di/register_di.ts b/asp-review-app/server/src/core/di/register_di.ts index ad79975..77f2abe 100644 --- a/asp-review-app/server/src/core/di/register_di.ts +++ b/asp-review-app/server/src/core/di/register_di.ts @@ -5,20 +5,24 @@ import { AssemblyController } from "../../features/assembly_create/assembly_crea import { AssemblyPreviewsController } from "../../features/assembly_previews/assembly_previews_controller"; import { EntityRepository } from "../repository/entity_repository"; import { ZipRepository } from "../repository/zip_repository"; +import { ComputeRepository } from "../repository/compute_repository"; export const locator = (env: Env) => { // override(Env, env) - registerRepository(env) registerController(env) + registerRepository(env) + }; const registerRepository = (env:Env) => { + override(ZipRepository, ZipRepository); - override(EntityRepository, EntityRepository) + override(EntityRepository, EntityRepository); + override(ComputeRepository,ComputeRepository); } const registerController = (env: Env) => { override(AssemblyController,AssemblyController) - override(AssemblyPreviewsController, AssemblyController) + override(AssemblyPreviewsController, AssemblyPreviewsController) } \ No newline at end of file diff --git a/asp-review-app/server/src/core/helper/memorization.ts b/asp-review-app/server/src/core/helper/memorization.ts index 0d5e87a..b936460 100644 --- a/asp-review-app/server/src/core/helper/memorization.ts +++ b/asp-review-app/server/src/core/helper/memorization.ts @@ -1,8 +1,4 @@ interface MemoOptions { - /** - * Serialize the function call arguments - * This is used to identify cache key - */ serialize?: (...args: Parameters) => S; } interface MemoAsyncOptions extends MemoOptions { @@ -22,16 +18,12 @@ type Fn = (...params: any[]) => any; type AsyncFn = (...params: any[]) => Promise; interface MemoFunc { - // Call the target function, if cache is valid, return cache (...args: Parameters): ReturnType; - // Same with this function get(...args: Parameters): ReturnType; - // Call the raw function and skip cache raw(...args: Parameters): ReturnType; - // Clear cache clear(...args: Parameters | []): void | Promise; } @@ -126,7 +118,6 @@ export function memoAsync( const root = makeNode(); const memoFunc = async function (...args: Parameters) { - // Serialize args const path = options.serialize ? options.serialize(...args) : args; const cur = walkAndCreate(root, path); @@ -155,7 +146,6 @@ export function memoAsync( await options.external.set(args, value); } - // Resolve other waiting callbacks for (const callback of cur.callbacks ?? []) { callback.res(value); } @@ -165,7 +155,6 @@ export function memoAsync( cur.state = State.Error; cur.error = error; - // Reject other waiting callbacks for (const callback of cur.callbacks ?? []) { callback.rej(error); } diff --git a/asp-review-app/server/src/core/middlewares/ValidationMiddleware.ts b/asp-review-app/server/src/core/middlewares/ValidationMiddleware.ts index d9ca9ca..d1ee527 100644 --- a/asp-review-app/server/src/core/middlewares/ValidationMiddleware.ts +++ b/asp-review-app/server/src/core/middlewares/ValidationMiddleware.ts @@ -11,7 +11,6 @@ const validationMiddleware = ( forbidNonWhitelisted = true, ): RequestHandler => { return (req, res, next) => { - console.log(req[value]) validate(plainToClass(type, req[value]), { skipMissingProperties, whitelist, forbidNonWhitelisted }).then((errors: ValidationError[]) => { if (errors.length > 0) { const message = errors.map((error: ValidationError) => Object.values(error.constraints)).join(', '); diff --git a/asp-review-app/server/src/core/repository/compute_repository.ts b/asp-review-app/server/src/core/repository/compute_repository.ts index eda546b..2b6ac30 100644 --- a/asp-review-app/server/src/core/repository/compute_repository.ts +++ b/asp-review-app/server/src/core/repository/compute_repository.ts @@ -1,3 +1,76 @@ -export class ComputeRepository{ - -} \ No newline at end of file +import { reflection } from 'first-di'; +import "reflect-metadata"; +import { promises as fs } from 'fs'; +import { async } from 'node-stream-zip'; +import * as cp from 'child_process'; + +import path from 'path'; + +async function exec(cmd: string, opts: (cp.ExecOptions & { trim?: boolean }) = {}): Promise { + return new Promise((c, e) => { + cp.exec(cmd, { env: process.env, ...opts }, (err, stdout) => err ? e(err) : c(opts.trim ? stdout.trim() : stdout)); + }); +} + +@reflection +export class ComputeRepository { + public computedAdjaxedMatrix = async (outPath: string, cadEntity: string, entityId: string) => { + const envPath = '/home/idontsudo/t/framework/asp-review-app/server/computed/geometric_feasibility_predicate/env.json' + const computedScript = '/home/idontsudo/t/framework/asp-review-app/server/computed/geometric_feasibility_predicate/main.py' + const computedComand = 'freecadcmd' + + const env = JSON.parse((await fs.readFile(envPath)).toString()) + env['cadFilePath'] = cadEntity + env['outPath'] = outPath + await fs.writeFile(envPath, JSON.stringify(env)) + // console.log(this._computedPath(computedScript)) + exec(computedComand + ' ' + computedScript, { cwd: this._computedPath(computedScript) }).then((data) => { + console.log(data) + }) + this.cadGeneration(cadEntity, entityId, outPath) + // if (stderr) { + // console.log(stderr) + // } + // console.log(stdout) + }; + public computedWriteStability = async (assemblyFolder: string, buildNumber: string, id: string) => { + const computedScript = '/home/idontsudo/t/framework/cad_stability_input/main.py' + const computedComand = 'freecad' + const envPath = '/home/idontsudo/t/framework/cad_stability_input/env.json' + const env = JSON.parse((await fs.readFile(envPath)).toString()) + env.assemblyFolder = assemblyFolder + env['projectId'] = id + env['buildNumber'] = buildNumber + env['assemblyFolder'] = assemblyFolder + env['resultURL'] = 'http://localhost:3002/assembly/stabilty/create/?id=' + id + '&' + 'buildNumber=' + buildNumber + + await fs.writeFile(envPath, JSON.stringify(env)) + await exec(computedComand + ' ' + computedScript, { cwd: this._computedPath(computedScript) }) + } + + private _computedPath(f: string) { + + const file = path.basename(f); + const absolutPath = path.resolve(f) + return absolutPath.replace(file, '') + } + + public cadGeneration = async (cadEntity, entity: string, outPath: string,) => { + const computedScript = '/home/idontsudo/t/framework/cad_generation/main.py' + const computedComand = 'freecad' + const envPath = '/home/idontsudo/t/framework/cad_generation/env.json' + + const env = JSON.parse((await fs.readFile(envPath)).toString()) + env.doc = cadEntity + env.projectId = entity + env.resultURL = "http://localhost:3002/assembly/save/out" + + await fs.writeFile(envPath, JSON.stringify(env)) + // /stabilty/create + + exec(computedComand + ' ' + computedScript, { cwd: this._computedPath(computedScript) }).then((data) => { + console.log(data) + }) + } + +} diff --git a/asp-review-app/server/src/core/repository/entity_repository.ts b/asp-review-app/server/src/core/repository/entity_repository.ts index 97277e6..cea7376 100644 --- a/asp-review-app/server/src/core/repository/entity_repository.ts +++ b/asp-review-app/server/src/core/repository/entity_repository.ts @@ -1,49 +1,86 @@ import { promises as fs } from 'fs'; import { dirname } from '../../app'; import fsSync from "fs"; -import { constants } from 'buffer'; +import { autowired, reflection } from 'first-di'; +import "reflect-metadata"; +import { ComputeRepository } from './compute_repository'; +import { ZipRepository } from './zip_repository'; +@reflection export class EntityRepository { - private path: String = dirname + '/public/' - private getFileName(file: String) { + @autowired() + private readonly computedRepository: ComputeRepository; + @autowired() + private readonly zipRepository: ZipRepository; + + private path: String = dirname + '/public/' + + + private getFileName(file: String) { return file.slice(0, file.indexOf('.')) } - public async getDir(path){ + + public async getDir(path) { return this._fullPath(await fs.readdir(path + ''), duplicatedDelete(this.path, path)) } - public isExistDirPath(path:String):boolean{ + + public isExistDirPath(path: String): boolean { return fsSync.existsSync(path + '') } + public async saveRootEntity(buffer: Buffer, name: string) { const filePath = this.path + this.getFileName(name) + '/' - + if (this.isExistDirPath(filePath)) { await fs.rm(filePath, { recursive: true }) } await fs.mkdir(filePath); await fs.writeFile(filePath + name, buffer); + this.computedRepository.computedAdjaxedMatrix(filePath, filePath + name, this.getFileName(name)) } + public async getAllRootEntity() { return await fs.readdir('' + this.path) } - public async getEntityStorage(entity: string):Promise | undefined { - return this._fullPath(await fs.readdir(this.path + entity), entity + '/' ) + + public async getEntityStorage(entity: string): Promise | undefined { + return this._fullPath(await fs.readdir(this.path + entity), entity + '/') } - private _fullPath(folderPath,helpElement = '') { - return folderPath.map((el) => this.path + helpElement + el ) + private _fullPath(folderPath, helpElement = '') { + return folderPath.map((el) => this.path + helpElement + el) } public async readJson(path) { - return JSON.parse((await fs.readFile(path)).toString()) } + public async saveGeration(data: Buffer, id: String) { + const rootFolderPath = '' + this.path + id + '/' + console.log(rootFolderPath) + this.zipRepository.archive(rootFolderPath, data) + } + public computedStability(id: string, buildNumber: string) { + const assemblyFolder = this.path + id + '/generation/' + this.computedRepository.computedWriteStability(assemblyFolder, buildNumber, id) + } + public async saveStability(zip: Buffer, id:string, buildNumber:string) { + const filePath = await this.zipRepository.archive(this.path as string, zip) + // const buildNumber = data['buildNumber'] + const assemblyFolder = this.path + id + '/generation/stability/' + + if (!this.isExistDirPath(assemblyFolder)) { + await fs.mkdir(assemblyFolder); + } + await this.zipRepository.archive(assemblyFolder as string, zip, buildNumber) + fs.rmdir(filePath + '/', { recursive: true}) + + } } -function duplicatedDelete(strChild:String,strMain:String){ +function duplicatedDelete(strChild: String, strMain: String) { let result = '' - for(let i = 0;i < strMain.length; i++){ - if(!(strMain[i] === strChild[i])){ - result+=strMain[i] + for (let i = 0; i < strMain.length; i++) { + if (!(strMain[i] === strChild[i])) { + result += strMain[i] } } return result diff --git a/asp-review-app/server/src/core/repository/zip_repository.ts b/asp-review-app/server/src/core/repository/zip_repository.ts index c27de1b..25efe1c 100644 --- a/asp-review-app/server/src/core/repository/zip_repository.ts +++ b/asp-review-app/server/src/core/repository/zip_repository.ts @@ -1,3 +1,13 @@ +import StreamZip from 'node-stream-zip'; +import { promises as fs } from 'fs'; +import decompress from 'decompress' + export class ZipRepository { - + public async archive(outhPath: string, zipFile: Buffer, name='generation') { + const entry = outhPath + 'archive.zip' + await fs.writeFile(entry, zipFile) + await decompress(entry, outhPath + name); + fs.rm(entry) + return outhPath + name + } } \ No newline at end of file diff --git a/asp-review-app/server/src/features/assembly_create/assembly_create_controller.ts b/asp-review-app/server/src/features/assembly_create/assembly_create_controller.ts index f229694..77e0a8b 100644 --- a/asp-review-app/server/src/features/assembly_create/assembly_create_controller.ts +++ b/asp-review-app/server/src/features/assembly_create/assembly_create_controller.ts @@ -1,36 +1,101 @@ -import { NextFunction, Request, Response } from 'express'; -import { autowired } from 'first-di'; - -import "reflect-metadata"; -import { dirname } from '../../app'; -import { EntityRepository } from '../../core/repository/entity_repository'; -import { IFile } from './model/zip_files_model'; - +import { NextFunction, Request, Response } from "express"; +import { autowired } from "first-di"; +import { async } from "node-stream-zip"; +import { EntityRepository } from "../../core/repository/entity_repository"; +import { IFile } from "./model/zip_files_model"; export class AssemblyController { - public getAllAssembly = (req: Request, res: Response, next: NextFunction): void => { - throw new Error('Method not implemented.'); - } - - @autowired() - private readonly fsRepository: EntityRepository; - - public createAssembly = (req: Request, res: Response, next: NextFunction): void => { + private readonly entityRepository: EntityRepository; + + public createRootEntity = ( + req: Request, + res: Response, + next: NextFunction + ) => { + const file = req.files; + const cadFile = file["freecad"] as IFile; + + this.entityRepository.saveRootEntity(cadFile.data, cadFile.name); + + res.status(200).json("ok"); + return; + }; + + public getAllAssembly = ( + req: Request, + res: Response, + next: NextFunction + ): void => { }; + + public createAssembly = ( + req: Request, + res: Response, + next: NextFunction + ): void => { try { const file = req.files.freecad as IFile; const buffer = file.data as Buffer; - console.log(file.data) - // console.log(files.freecad.data) - // const filePath = dirname + '/' + files.freecad.name as string; - this.fsRepository.saveRootEntity(file.data, file.name) - // console.log(filePath) - + this.entityRepository.saveRootEntity(file.data, file.name); res.sendStatus(200); } catch (error) { next(error); } }; -} - \ No newline at end of file + + public test = (req: Request, + res: Response, + next: NextFunction) => { + try { + const file = req.files; + + const generation = file["zip"] as IFile; + const id = 'cubes'; + + this.entityRepository.saveGeration(generation.data, id) + res.sendStatus(200); + } catch (error) { + next(error); + } + } + + public stabilityComputed = async ( + req: Request, + res: Response, + next: NextFunction + ) => { + try { + // const file = req.files; + console.log(req.body) + const id = req.body.id; + // console.log(req.query.id) + const buildNumber = req.body.buildNumber; + console.log(buildNumber) + console.log(id) + // const generation = file["zip"] as IFile; + // const id = 'cubes'; + + await this.entityRepository.computedStability(id, buildNumber) + res.sendStatus(200); + } catch (error) { + next(error); + } + } + + public stabilityCreate = ( + req: Request, + res: Response, + next: NextFunction + ) => { + try { + const files = req.files; + const zip = files['zip'] as IFile + const query = req.query as any + this.entityRepository.saveStability(zip.data, query.id, query.buildNumber) + res.sendStatus(200); + } catch (error) { + next(error); + } + } +} diff --git a/asp-review-app/server/src/features/assembly_create/assembly_create_route.ts b/asp-review-app/server/src/features/assembly_create/assembly_create_route.ts index 4449101..43fefe1 100644 --- a/asp-review-app/server/src/features/assembly_create/assembly_create_route.ts +++ b/asp-review-app/server/src/features/assembly_create/assembly_create_route.ts @@ -1,26 +1,46 @@ - -import express, { Router } from 'express'; -import { Routes } from '../../core/interfaces/router'; -import { autowired } from 'first-di'; -import { AssemblyController } from './assembly_create_controller'; -import path from 'path'; -import { dirname } from '../../app'; -import validationMiddleware from '../../core/middlewares/ValidationMiddleware'; -import { CadFilesModel } from './model/zip_files_model'; +import express, { Router } from "express"; +import { Routes } from "../../core/interfaces/router"; +import { autowired } from "first-di"; +import { AssemblyController } from "./assembly_create_controller"; +import validationMiddleware from "../../core/middlewares/ValidationMiddleware"; +import { CadFilesModel } from "./model/zip_files_model"; export class AssemblyRoute implements Routes { - public path = '/assembly'; - public router = Router(); - @autowired() - private readonly assemblyController: AssemblyController; - constructor() { - this.initializeRoutes(); - } + public path = "/assembly"; + public router = Router(); + + @autowired() + private readonly assemblyController: AssemblyController; + + constructor() { + this.initializeRoutes(); + } - private initializeRoutes() { - // this.router.use(`${this.path}`, express.static(path.join(dirname, '../../public'))); - this.router.post(`${this.path}`, validationMiddleware(CadFilesModel, 'files'), this.assemblyController.createAssembly) + private initializeRoutes() { + this.router.post( + `${this.path}`, + validationMiddleware(CadFilesModel, "files"), + this.assemblyController.createAssembly + ); + this.router.post( + `${this.path}/save/out`, + // validationMiddleware(CadFilesModel, "files"), + this.assemblyController.test + ); - this.router.get(`${this.path}`, this.assemblyController.getAllAssembly) - } -} \ No newline at end of file + this.router.get(`${this.path}`, this.assemblyController.getAllAssembly); + + this.router.post( + `${this.path}/create`, + this.assemblyController.createRootEntity + ); + this.router.post( + `${this.path}/stability/write/computed`, + this.assemblyController.stabilityComputed + ); + this.router.post( + `${this.path}/stabilty/create/`, + this.assemblyController.stabilityCreate + ); + } +} diff --git a/asp-review-app/server/src/features/assembly_create/model/zip_files_model.ts b/asp-review-app/server/src/features/assembly_create/model/zip_files_model.ts index 243f69c..99956e0 100644 --- a/asp-review-app/server/src/features/assembly_create/model/zip_files_model.ts +++ b/asp-review-app/server/src/features/assembly_create/model/zip_files_model.ts @@ -1,4 +1,5 @@ import { IsArray, IsObject } from "class-validator"; + export interface IFile { name: string, data: Buffer, @@ -9,9 +10,11 @@ export interface IFile { mimetype: string, md5: string, } + interface ICadFileModel { freecad: IFile; } + export class CadFilesModel implements ICadFileModel { @IsObject() public freecad: IFile; diff --git a/asp-review-app/server/src/features/assembly_previews/assembly_previews_controller.ts b/asp-review-app/server/src/features/assembly_previews/assembly_previews_controller.ts index b071b9f..68429e0 100644 --- a/asp-review-app/server/src/features/assembly_previews/assembly_previews_controller.ts +++ b/asp-review-app/server/src/features/assembly_previews/assembly_previews_controller.ts @@ -3,10 +3,7 @@ import { autowired } from "first-di"; import { EntityRepository } from "../../core/repository/entity_repository"; import { port } from "../../server"; import { memoAsync } from "../../core/helper/memorization"; - -import "reflect-metadata"; -import { async } from "node-stream-zip"; - + export class AssemblyPreviewsController { @autowired() private readonly entityRepository: EntityRepository; @@ -32,8 +29,9 @@ export class AssemblyPreviewsController { const entity = await this.entityRepository.getEntityStorage( req.params.id ); + const aspUsage = Number(req.query.count) - 1; - console.log(aspUsage); + if (entity === undefined) { res.status(404).json("entity not found"); return; @@ -59,10 +57,13 @@ export class AssemblyPreviewsController { next: NextFunction ) => { const entity = await this.entityRepository.getEntityStorage(req.params.id); + const aspUsage = Number(req.query.count); + const assemblyFolder = entity.find((el) => { return el.match("assembly"); }); + const asmCountFolder = "0000" + aspUsage; const assemblyDirPath = assemblyFolder + "/" + asmCountFolder; @@ -70,12 +71,15 @@ export class AssemblyPreviewsController { if (!this.entityRepository.isExistDirPath(assemblyDirPath)) { return res.status(400).json({ error: "bad request" }); } + const assemblyProcessDir = await this.entityRepository.getDir( assemblyDirPath + "/process/" ); + const firstObj = assemblyProcessDir.find((el) => { return el.match("1.obj"); }); + const zeroObj = await assemblyProcessDir.find((el) => { return el.match("0.obj"); }); @@ -148,4 +152,5 @@ export class AssemblyPreviewsController { }; } } + } diff --git a/asp-review-app/server/src/features/assembly_previews/assembly_previews_route.ts b/asp-review-app/server/src/features/assembly_previews/assembly_previews_route.ts index ef326cd..c12658c 100644 --- a/asp-review-app/server/src/features/assembly_previews/assembly_previews_route.ts +++ b/asp-review-app/server/src/features/assembly_previews/assembly_previews_route.ts @@ -12,16 +12,16 @@ export class AssemblyPreviewsRoute implements Routes { public path = '/assembly/preview/'; public router = Router(); @autowired() - private readonly assemblyController: AssemblyPreviewsController; + private readonly assemblyPreviewsController: AssemblyPreviewsController; constructor() { this.initializeRoutes(); } private initializeRoutes() { - this.router.get(`${this.path}`, this.assemblyController.getAllAssembly); + this.router.get(`${this.path}`, this.assemblyPreviewsController.getAllAssembly); // this.router.get(`${this.path}`) - this.router.get(`${this.path}subsequence/:id`, this.assemblyController.getAssemblySubsequenceById) - this.router.get(`${this.path}insertion_sequence/:id`, this.assemblyController.getAssemblyInsertionSequenceById) + this.router.get(`${this.path}subsequence/:id`, this.assemblyPreviewsController.getAssemblySubsequenceById) + this.router.get(`${this.path}insertion_sequence/:id`, this.assemblyPreviewsController.getAssemblyInsertionSequenceById) // this.router.post(`${this.path}`, validationMiddleware(CadFilesModel, 'files'), this.assemblyController.createAssembly) // this.router.get(`${this.path}`, this.assemblyController.getAllAssembly) diff --git a/asp-review-app/ui/package-lock.json b/asp-review-app/ui/package-lock.json index ab05d8c..519297f 100644 --- a/asp-review-app/ui/package-lock.json +++ b/asp-review-app/ui/package-lock.json @@ -17,8 +17,8 @@ "@testing-library/user-event": "^13.2.1", "@types/jest": "^27.0.1", "@types/node": "^16.7.13", - "@types/react": "^18.0.0", - "@types/react-dom": "^18.0.0", + "@types/react": "18.0.25", + "@types/react-dom": "18.0.9", "antd": "^5.5.2", "babel-jest": "^27.4.2", "babel-loader": "^8.2.3", @@ -55,16 +55,21 @@ "postcss-normalize": "^10.0.1", "postcss-preset-env": "^7.0.1", "prompts": "^2.4.2", - "react": "^16.12.0", + "react": "18.0.0", "react-app-polyfill": "^3.0.0", "react-dev-utils": "^12.0.1", - "react-dom": "^16.12.0", + "react-dom": "18.0.0", "react-i18next": "^12.2.0", "react-refresh": "^0.11.0", "react-router-dom": "^6.11.2", "react-three-fiber": "^6.0.13", "resolve": "^1.20.0", "resolve-url-loader": "^4.0.0", + "rete": "2.0.0-beta.9", + "rete-area-plugin": "2.0.0-beta.12", + "rete-connection-plugin": "2.0.0-beta.16", + "rete-react-render-plugin": "2.0.0-beta.22", + "rete-render-utils": "2.0.0-beta.12", "sass-loader": "^12.3.0", "semver": "^7.3.5", "sort-by": "^1.2.0", @@ -110,9 +115,9 @@ } }, "node_modules/@ant-design/cssinjs": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/@ant-design/cssinjs/-/cssinjs-1.9.1.tgz", - "integrity": "sha512-CZt1vCMs/sY7RoacYuIkZwQmb8Bhp99ReNNE9Y8lnUzik8fmCdKAQA7ecvVOFwmNFdcBHga7ye/XIRrsbkiqWw==", + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/@ant-design/cssinjs/-/cssinjs-1.10.1.tgz", + "integrity": "sha512-PSoJS8RMzn95ZRg007dJGr6AU0Zim/O+tTN0xmXmh9CkIl4y3wuOr2Zhehaj7s130wPSYDVvahf3DKT50w/Zhw==", "dependencies": { "@babel/runtime": "^7.11.1", "@emotion/hash": "^0.8.0", @@ -2370,6 +2375,27 @@ "resolved": "https://registry.npmjs.org/@emotion/hash/-/hash-0.8.0.tgz", "integrity": "sha512-kBJtf7PH6aWwZ6fka3zQ0p6SBYzx4fl1LoZXE2RrnYST9Xljm7WfKJrU4g/Xr3Beg72MLrp1AWNUmuYJTL7Cow==" }, + "node_modules/@emotion/is-prop-valid": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-1.2.1.tgz", + "integrity": "sha512-61Mf7Ufx4aDxx1xlDeOm8aFFigGHE4z+0sKCa+IHCeZKiyP9RLD0Mmx7m8b9/Cf37f7NAvQOOJAbQQGVr5uERw==", + "peer": true, + "dependencies": { + "@emotion/memoize": "^0.8.1" + } + }, + "node_modules/@emotion/memoize": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.8.1.tgz", + "integrity": "sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA==", + "peer": true + }, + "node_modules/@emotion/stylis": { + "version": "0.8.5", + "resolved": "https://registry.npmjs.org/@emotion/stylis/-/stylis-0.8.5.tgz", + "integrity": "sha512-h6KtPihKFn3T9fuIrwvXXUOwlx3rfUvfZIcP5a6rh8Y7zjE3O06hT5Ss4S/YI1AYhuZ1kjaE/5EaOOI2NqSylQ==", + "peer": true + }, "node_modules/@emotion/unitless": { "version": "0.7.5", "resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.7.5.tgz", @@ -3048,9 +3074,9 @@ } }, "node_modules/@rc-component/mini-decimal": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@rc-component/mini-decimal/-/mini-decimal-1.0.1.tgz", - "integrity": "sha512-9N8nRk0oKj1qJzANKl+n9eNSMUGsZtjwNuDCiZ/KA+dt1fE3zq5x2XxclRcAbOIXnZcJ53ozP2Pa60gyELXagA==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@rc-component/mini-decimal/-/mini-decimal-1.1.0.tgz", + "integrity": "sha512-jS4E7T9Li2GuYwI6PyiVXmxTiM6b07rlD9Ge8uGZSCz3WlzcG5ZK7g5bbuKNeZ9pgUuPK/5guV781ujdVpm4HQ==", "dependencies": { "@babel/runtime": "^7.18.0" }, @@ -3112,9 +3138,9 @@ } }, "node_modules/@rc-component/trigger": { - "version": "1.13.3", - "resolved": "https://registry.npmjs.org/@rc-component/trigger/-/trigger-1.13.3.tgz", - "integrity": "sha512-CA4s8QGj2kagp8dmYRVcSIW5IErw/YBxSeFEsQmt6SB0oaj9pj+akkB6O0S/Y6ww5JrIDu9Bukq89se1oW9F3w==", + "version": "1.13.6", + "resolved": "https://registry.npmjs.org/@rc-component/trigger/-/trigger-1.13.6.tgz", + "integrity": "sha512-13aF9SrR5XAd+tyV/zja0A2pbrA/zdTCXRBNIsoLp8OmhVOnqiwjP7XZYPulLsH0ioEfvtXR1yI0anJD0/J7PQ==", "dependencies": { "@babel/runtime": "^7.18.3", "@rc-component/portal": "^1.1.0", @@ -3122,7 +3148,7 @@ "rc-align": "^4.0.0", "rc-motion": "^2.0.0", "rc-resize-observer": "^1.3.1", - "rc-util": "^5.31.1" + "rc-util": "^5.33.0" }, "engines": { "node": ">=8.x" @@ -4000,9 +4026,9 @@ "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==" }, "node_modules/@types/react": { - "version": "18.0.32", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.32.tgz", - "integrity": "sha512-gYGXdtPQ9Cj0w2Fwqg5/ak6BcK3Z15YgjSqtyDizWUfx7mQ8drs0NBUzRRsAdoFVTO8kJ8L2TL8Skm7OFPnLUw==", + "version": "18.0.25", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.25.tgz", + "integrity": "sha512-xD6c0KDT4m7n9uD4ZHi02lzskaiqcBxf4zi+tXZY98a04wvc0hi/TcCPC2FOESZi51Nd7tlUeOJY8RofL799/g==", "dependencies": { "@types/prop-types": "*", "@types/scheduler": "*", @@ -4010,9 +4036,9 @@ } }, "node_modules/@types/react-dom": { - "version": "18.0.11", - "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.0.11.tgz", - "integrity": "sha512-O38bPbI2CWtgw/OoQoY+BRelw7uysmXbWvw3nLWO21H1HSh+GOlqPuXshJfjmpNlKiiSDG9cc1JZAaMmVdcTlw==", + "version": "18.0.9", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.0.9.tgz", + "integrity": "sha512-qnVvHxASt/H7i+XG1U1xMiY5t+IHcPGUK7TDMDzom08xa7e86eCeKOiLZezwCKVxJn6NEiiy2ekgX8aQssjIKg==", "dependencies": { "@types/react": "*" } @@ -5178,6 +5204,28 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/babel-plugin-styled-components": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/babel-plugin-styled-components/-/babel-plugin-styled-components-2.1.3.tgz", + "integrity": "sha512-jBioLwBVHpOMU4NsueH/ADcHrjS0Y/WTpt2eGVmmuSFNEv2DF3XhcMncuZlbbjxQ4vzxg+yEr6E6TNjrIQbsJQ==", + "peer": true, + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.18.6", + "@babel/helper-module-imports": "^7.21.4", + "babel-plugin-syntax-jsx": "^6.18.0", + "lodash": "^4.17.21", + "picomatch": "^2.3.1" + }, + "peerDependencies": { + "styled-components": ">= 2" + } + }, + "node_modules/babel-plugin-syntax-jsx": { + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.18.0.tgz", + "integrity": "sha512-qrPaCSo9c8RHNRHIotaufGbuOBN8rtdC4QrrFFc43vyWCCz7Kl7GL1PGaXtMGQZUXrkCjNEgxDfmAuAabr/rlw==", + "peer": true + }, "node_modules/babel-plugin-transform-react-remove-prop-types": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/babel-plugin-transform-react-remove-prop-types/-/babel-plugin-transform-react-remove-prop-types-0.4.24.tgz", @@ -5499,6 +5547,15 @@ "node": ">= 6" } }, + "node_modules/camelize": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/camelize/-/camelize-1.0.1.tgz", + "integrity": "sha512-dU+Tx2fsypxTgtLoE36npi3UqcjSSMNYfkqgmoEhtZrraP5VWq0K7FkWVTYa8eMPtnU/G2txVsfdCJTn9uzpuQ==", + "peer": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/camera-controls": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/camera-controls/-/camera-controls-2.3.4.tgz", @@ -6042,6 +6099,15 @@ "postcss": "^8.4" } }, + "node_modules/css-color-keywords": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/css-color-keywords/-/css-color-keywords-1.0.0.tgz", + "integrity": "sha512-FyyrDHZKEjXDpNJYvVsV960FiqQyXc/LlYmsxl2BcdMb2WPx0OGRVgTg55rPSyLSNMqP52R9r8geSp7apN3Ofg==", + "peer": true, + "engines": { + "node": ">=4" + } + }, "node_modules/css-declaration-sorter": { "version": "6.4.0", "resolved": "https://registry.npmjs.org/css-declaration-sorter/-/css-declaration-sorter-6.4.0.tgz", @@ -6223,6 +6289,17 @@ "resolved": "https://registry.npmjs.org/css-select-base-adapter/-/css-select-base-adapter-0.1.1.tgz", "integrity": "sha512-jQVeeRG70QI08vSTwf1jHxp74JoZsr2XSgETae8/xC8ovSnL2WF87GTLO86Sbwdt2lK4Umg4HnnwMO4YF3Ce7w==" }, + "node_modules/css-to-react-native": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/css-to-react-native/-/css-to-react-native-3.2.0.tgz", + "integrity": "sha512-e8RKaLXMOFii+02mOlqwjbD00KSEKqblnpO9e++1aXS1fPQOpS1YoqdVHBqPjHNoxeF2mimzVqawm2KCbEdtHQ==", + "peer": true, + "dependencies": { + "camelize": "^1.0.0", + "css-color-keywords": "^1.0.0", + "postcss-value-parser": "^4.0.2" + } + }, "node_modules/css-tree": { "version": "1.0.0-alpha.37", "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-1.0.0-alpha.37.tgz", @@ -8567,6 +8644,21 @@ "he": "bin/he" } }, + "node_modules/hoist-non-react-statics": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", + "integrity": "sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==", + "peer": true, + "dependencies": { + "react-is": "^16.7.0" + } + }, + "node_modules/hoist-non-react-statics/node_modules/react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", + "peer": true + }, "node_modules/hoopy": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/hoopy/-/hoopy-0.1.4.tgz", @@ -13266,9 +13358,9 @@ } }, "node_modules/rc-field-form": { - "version": "1.32.0", - "resolved": "https://registry.npmjs.org/rc-field-form/-/rc-field-form-1.32.0.tgz", - "integrity": "sha512-vr5pA0/gWiBZf0HKdevQJcWSsAac10Z8Nj1Brs3OOCnExk7l+u8GtsW+4cRSqJLug5fxV11dOGXpxf7+aHT/2A==", + "version": "1.32.2", + "resolved": "https://registry.npmjs.org/rc-field-form/-/rc-field-form-1.32.2.tgz", + "integrity": "sha512-SzqG1YGyD2P42ztZJ7qoPQp6FV9bD51RUdKGG/5xwybU1wbFdgWTqiMXkS8UR9L4GwXVMKh5PaF2I4EBXd/Rng==", "dependencies": { "@babel/runtime": "^7.18.0", "async-validator": "^4.1.0", @@ -13396,9 +13488,9 @@ } }, "node_modules/rc-overflow": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/rc-overflow/-/rc-overflow-1.3.0.tgz", - "integrity": "sha512-p2Qt4SWPTHAYl4oAao1THy669Fm5q8pYBDBHRaFOekCvcdcrgIx0ByXQMEkyPm8wUDX4BK6aARWecvCRc/7CTA==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/rc-overflow/-/rc-overflow-1.3.1.tgz", + "integrity": "sha512-RY0nVBlfP9CkxrpgaLlGzkSoh9JhjJLu6Icqs9E7CW6Ewh9s0peF9OHIex4OhfoPsR92LR0fN6BlCY9Z4VoUtA==", "dependencies": { "@babel/runtime": "^7.11.1", "classnames": "^2.2.1", @@ -13460,9 +13552,9 @@ } }, "node_modules/rc-progress": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/rc-progress/-/rc-progress-3.4.1.tgz", - "integrity": "sha512-eAFDHXlk8aWpoXl0llrenPMt9qKHQXphxcVsnKs0FHC6eCSk1ebJtyaVjJUzKe0233ogiLDeEFK1Uihz3s67hw==", + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/rc-progress/-/rc-progress-3.4.2.tgz", + "integrity": "sha512-iAGhwWU+tsayP+Jkl9T4+6rHeQTG9kDz8JAHZk4XtQOcYN5fj9H34NXNEdRdZx94VUDHMqCb1yOIvi8eJRh67w==", "dependencies": { "@babel/runtime": "^7.10.1", "classnames": "^2.2.6", @@ -13521,9 +13613,9 @@ } }, "node_modules/rc-select": { - "version": "14.5.1", - "resolved": "https://registry.npmjs.org/rc-select/-/rc-select-14.5.1.tgz", - "integrity": "sha512-RQ3yiguq6yJ+kbtip7/6RTq2hOotS/s00nyZL2nxyz5194C6uOtSB8Kgsw3c6ZXII1EDjuJX3zLI1pkxkNWyww==", + "version": "14.5.2", + "resolved": "https://registry.npmjs.org/rc-select/-/rc-select-14.5.2.tgz", + "integrity": "sha512-Np/lDHvxCnVhVsheQjSV1I/OMJTWJf1n10wq8q1AGy3ytyYLfjNpi6uaz/pmjsbbiSddSWzJnNZCli9LmgBZsA==", "dependencies": { "@babel/runtime": "^7.10.1", "@rc-component/trigger": "^1.5.0", @@ -13660,9 +13752,9 @@ } }, "node_modules/rc-tree": { - "version": "5.7.4", - "resolved": "https://registry.npmjs.org/rc-tree/-/rc-tree-5.7.4.tgz", - "integrity": "sha512-7VfDq4jma+6fvlzfDXvUJ34SaO2EWkcXGBmPgeFmVKsLNNXcKGl4cRAhs6Ts1zqnX994vu/hb3f1dyTjn43RFg==", + "version": "5.7.5", + "resolved": "https://registry.npmjs.org/rc-tree/-/rc-tree-5.7.5.tgz", + "integrity": "sha512-iyM60rUdJh+KinxSjtZ40eox/DdjIwCUM4oBUoOLyrSwXsaoVZtpcVgWwZExjgHp4MSsn3FhVSntO/5c3aMbSQ==", "dependencies": { "@babel/runtime": "^7.10.1", "classnames": "2.x", @@ -13728,9 +13820,9 @@ } }, "node_modules/rc-util": { - "version": "5.32.4", - "resolved": "https://registry.npmjs.org/rc-util/-/rc-util-5.32.4.tgz", - "integrity": "sha512-LRQpfPjtLbN9BrNgU/evbQrhTLfHepJPSKbhHF2Nm1cnNeZkSqXCKDTDPjMXa1VavcnJA1iP39O8PB0+Rc216Q==", + "version": "5.33.1", + "resolved": "https://registry.npmjs.org/rc-util/-/rc-util-5.33.1.tgz", + "integrity": "sha512-oMs2OIV/2lUCF8nllevzLccneyxAzdSOaHSs5y91qOLdqaLbIMsuL49C6/DhF/WKMqiAKEKGdVk2F1sB5HQe9A==", "dependencies": { "@babel/runtime": "^7.18.3", "react-is": "^16.12.0" @@ -13764,13 +13856,11 @@ } }, "node_modules/react": { - "version": "16.14.0", - "resolved": "https://registry.npmjs.org/react/-/react-16.14.0.tgz", - "integrity": "sha512-0X2CImDkJGApiAlcf0ODKIneSwBPhqJawOa5wCtKbu7ZECrmS26NvtSILynQ66cgkT/RJ4LidJOc3bUESwmU8g==", + "version": "18.0.0", + "resolved": "https://registry.npmjs.org/react/-/react-18.0.0.tgz", + "integrity": "sha512-x+VL6wbT4JRVPm7EGxXhZ8w8LTROaxPXOqhlGyVSrv0sB1jkyFGgXxJ8LVoPRLvPR6/CIZGFmfzqUa2NYeMr2A==", "dependencies": { - "loose-envify": "^1.1.0", - "object-assign": "^4.1.1", - "prop-types": "^15.6.2" + "loose-envify": "^1.1.0" }, "engines": { "node": ">=0.10.0" @@ -13846,26 +13936,15 @@ } }, "node_modules/react-dom": { - "version": "16.14.0", - "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.14.0.tgz", - "integrity": "sha512-1gCeQXDLoIqMgqD3IO2Ah9bnf0w9kzhwN5q4FGnHZ67hBm9yePzB5JJAIQCc8x3pFnNlwFq4RidZggNAAkzWWw==", + "version": "18.0.0", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.0.0.tgz", + "integrity": "sha512-XqX7uzmFo0pUceWFCt7Gff6IyIMzFUn7QMZrbrQfGxtaxXZIcGQzoNpRLE3fQLnS4XzLLPMZX2T9TRcSrasicw==", "dependencies": { "loose-envify": "^1.1.0", - "object-assign": "^4.1.1", - "prop-types": "^15.6.2", - "scheduler": "^0.19.1" + "scheduler": "^0.21.0" }, "peerDependencies": { - "react": "^16.14.0" - } - }, - "node_modules/react-dom/node_modules/scheduler": { - "version": "0.19.1", - "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.19.1.tgz", - "integrity": "sha512-n/zwRWRYSUj0/3g/otKDRPMh6qv2SYMWNq85IEa8iZyAv8od9zDYpGSnpBEjNgcMNq6Scbu5KfIPxNF72R/2EA==", - "dependencies": { - "loose-envify": "^1.1.0", - "object-assign": "^4.1.1" + "react": "^18.0.0" } }, "node_modules/react-error-overlay": { @@ -14272,6 +14351,67 @@ "node": ">=10" } }, + "node_modules/rete": { + "version": "2.0.0-beta.9", + "resolved": "https://registry.npmjs.org/rete/-/rete-2.0.0-beta.9.tgz", + "integrity": "sha512-tmQk0UIjG2qmCamT58Kg8kQQq30/Nal1zr2uqX4mH2L9rZKCUBAL2dWZ160FoRbfTzWr0oFP/7PYhWrYwhkWDA==", + "hasInstallScript": true, + "dependencies": { + "@babel/runtime": "^7.21.0" + } + }, + "node_modules/rete-area-plugin": { + "version": "2.0.0-beta.12", + "resolved": "https://registry.npmjs.org/rete-area-plugin/-/rete-area-plugin-2.0.0-beta.12.tgz", + "integrity": "sha512-F4JLAmCIKCrPr+HinR651cHfyocALZsF7ORRdOXTBMbsyvlRn0KsOz8HsR8t9+AQbcMb45YXFKO+7QG4WvZQ6w==", + "dependencies": { + "@babel/runtime": "^7.21.0" + }, + "peerDependencies": { + "rete": "^2.0.0-beta.9" + } + }, + "node_modules/rete-connection-plugin": { + "version": "2.0.0-beta.16", + "resolved": "https://registry.npmjs.org/rete-connection-plugin/-/rete-connection-plugin-2.0.0-beta.16.tgz", + "integrity": "sha512-jniCW/Mt4gPey46eK9or5aguHf8DSbSZa7fUzzRxpnnmO3MpMXoDj8AKjfoKSR24PXK3Xz1prjAg8OEP7YXRDQ==", + "dependencies": { + "@babel/runtime": "^7.21.0" + }, + "peerDependencies": { + "rete": "^2.0.0-beta.9", + "rete-area-plugin": "^2.0.0-beta.12" + } + }, + "node_modules/rete-react-render-plugin": { + "version": "2.0.0-beta.22", + "resolved": "https://registry.npmjs.org/rete-react-render-plugin/-/rete-react-render-plugin-2.0.0-beta.22.tgz", + "integrity": "sha512-Tcqk6sQMqD8p6+bssarNczZT+MnLv9M1WngmZrfsJ36C1jFckR2A1rmJhqSmXiIE00wcmvBeXblKTHqdFln/Kw==", + "dependencies": { + "@babel/runtime": "^7.21.0", + "usehooks-ts": "^2.9.1" + }, + "peerDependencies": { + "react": "^16.8.6 || ^17 || ^18", + "react-dom": "^16.8.6 || ^17 || ^18", + "rete": "^2.0.0-beta.9", + "rete-area-plugin": "^2.0.0-beta.12", + "rete-render-utils": "^2.0.0-beta.12", + "styled-components": "^5.3.6" + } + }, + "node_modules/rete-render-utils": { + "version": "2.0.0-beta.12", + "resolved": "https://registry.npmjs.org/rete-render-utils/-/rete-render-utils-2.0.0-beta.12.tgz", + "integrity": "sha512-aRXyGQbF9Y9zIg/TuXFXrz+AVj74FLGGONdF/12okPqwm30aUXA3YakdHONfiaxRi/Ibvmrq7nLI+3wU64K4Xw==", + "dependencies": { + "@babel/runtime": "^7.21.0" + }, + "peerDependencies": { + "rete": "^2.0.0-beta.9", + "rete-area-plugin": "^2.0.0-beta.12" + } + }, "node_modules/retry": { "version": "0.13.1", "resolved": "https://registry.npmjs.org/retry/-/retry-0.13.1.tgz", @@ -14687,6 +14827,12 @@ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" }, + "node_modules/shallowequal": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/shallowequal/-/shallowequal-1.1.0.tgz", + "integrity": "sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==", + "peer": true + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -15112,6 +15258,57 @@ "webpack": "^5.0.0" } }, + "node_modules/styled-components": { + "version": "5.3.11", + "resolved": "https://registry.npmjs.org/styled-components/-/styled-components-5.3.11.tgz", + "integrity": "sha512-uuzIIfnVkagcVHv9nE0VPlHPSCmXIUGKfJ42LNjxCCTDTL5sgnJ8Z7GZBq0EnLYGln77tPpEpExt2+qa+cZqSw==", + "peer": true, + "dependencies": { + "@babel/helper-module-imports": "^7.0.0", + "@babel/traverse": "^7.4.5", + "@emotion/is-prop-valid": "^1.1.0", + "@emotion/stylis": "^0.8.4", + "@emotion/unitless": "^0.7.4", + "babel-plugin-styled-components": ">= 1.12.0", + "css-to-react-native": "^3.0.0", + "hoist-non-react-statics": "^3.0.0", + "shallowequal": "^1.1.0", + "supports-color": "^5.5.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/styled-components" + }, + "peerDependencies": { + "react": ">= 16.8.0", + "react-dom": ">= 16.8.0", + "react-is": ">= 16.8.0" + } + }, + "node_modules/styled-components/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "peer": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/styled-components/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "peer": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/stylehacks": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/stylehacks/-/stylehacks-5.1.1.tgz", @@ -15985,6 +16182,19 @@ "requires-port": "^1.0.0" } }, + "node_modules/usehooks-ts": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/usehooks-ts/-/usehooks-ts-2.9.1.tgz", + "integrity": "sha512-2FAuSIGHlY+apM9FVlj8/oNhd+1y+Uwv5QNkMQz1oSfdHk4PXo1qoCw9I5M7j0vpH8CSWFJwXbVPeYDjLCx9PA==", + "engines": { + "node": ">=16.15.0", + "npm": ">=8" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", diff --git a/asp-review-app/ui/package.json b/asp-review-app/ui/package.json index 20ac1dd..cff1c44 100644 --- a/asp-review-app/ui/package.json +++ b/asp-review-app/ui/package.json @@ -12,8 +12,8 @@ "@testing-library/user-event": "^13.2.1", "@types/jest": "^27.0.1", "@types/node": "^16.7.13", - "@types/react": "^18.0.0", - "@types/react-dom": "^18.0.0", + "@types/react": "18.0.25", + "@types/react-dom": "18.0.9", "antd": "^5.5.2", "babel-jest": "^27.4.2", "babel-loader": "^8.2.3", @@ -50,16 +50,21 @@ "postcss-normalize": "^10.0.1", "postcss-preset-env": "^7.0.1", "prompts": "^2.4.2", - "react": "^16.12.0", + "react": "18.0.0", "react-app-polyfill": "^3.0.0", "react-dev-utils": "^12.0.1", - "react-dom": "^16.12.0", + "react-dom": "18.0.0", "react-i18next": "^12.2.0", "react-refresh": "^0.11.0", "react-router-dom": "^6.11.2", "react-three-fiber": "^6.0.13", "resolve": "^1.20.0", "resolve-url-loader": "^4.0.0", + "rete": "2.0.0-beta.9", + "rete-area-plugin": "2.0.0-beta.12", + "rete-connection-plugin": "2.0.0-beta.16", + "rete-react-render-plugin": "2.0.0-beta.22", + "rete-render-utils": "2.0.0-beta.12", "sass-loader": "^12.3.0", "semver": "^7.3.5", "sort-by": "^1.2.0", diff --git a/asp-review-app/ui/src/App.css b/asp-review-app/ui/src/App.css index 8e01787..3991e48 100644 --- a/asp-review-app/ui/src/App.css +++ b/asp-review-app/ui/src/App.css @@ -6,7 +6,39 @@ .root{ + overflow-y: hidden; +} +.centeredDiv{ + width: 100vw; display: flex; + justify-content: center; +} +.projects-container{ + width: 100%; + background-color: aliceblue; + display: flex; + flex-direction: column; + justify-content: space-evenly; + align-items: center; + overflow-y:hidden; +} +.centeredContainer{ + display: flex; + flex-direction: column; + align-content: center; + align-items: center; +} +label { + background-color: indigo; + color: white; + padding: 0.5rem; + font-family: sans-serif; + border-radius: 0.3rem; + cursor: pointer; + margin-top: 1rem; } - \ No newline at end of file +#file-chosen{ + margin-left: 0.3rem; + font-family: sans-serif; +} \ No newline at end of file diff --git a/asp-review-app/ui/src/core/repository/http_repository.ts b/asp-review-app/ui/src/core/repository/http_repository.ts index 5908cd5..3f2eed3 100644 --- a/asp-review-app/ui/src/core/repository/http_repository.ts +++ b/asp-review-app/ui/src/core/repository/http_repository.ts @@ -2,21 +2,34 @@ export enum HttpMethod { GET = 'GET', POST = 'POST' } -export enum HttpRoute{ +export enum HttpRoute { insertionPath = '/assembly/preview/insertion_sequence/', assemblyPreviewPath = '/assembly/preview/subsequence/', - projects = '/assembly/preview' + projects = '/assembly/preview', + createProject = '/assembly/create', + ajaxMatrix = 'matrix.json' } export class HttpRepository { static server = 'http://localhost:3002' - static async jsonRequest(method: HttpMethod, url: string, data?: any):Promise { + static async jsonRequest(method: HttpMethod, url: string, data?: any): Promise { const reqInit = { 'body': data, 'method': method, + 'headers': { 'Content-Type': 'application/json' }, } if (data !== undefined) { reqInit['body'] = JSON.stringify(data) } return (await fetch(this.server + url, reqInit)).json() } + static async request(method: HttpMethod, url: string, data?: any): Promise { + const reqInit = { + 'body': data, + 'method': method, + } + if (data !== undefined) { + reqInit['body'] = data + } + return (await fetch(this.server + url, reqInit)).json() + } } \ No newline at end of file diff --git a/asp-review-app/ui/src/features/all_project/all_project_screen.tsx b/asp-review-app/ui/src/features/all_project/all_project_screen.tsx index 3ba25f6..0bf8e16 100644 --- a/asp-review-app/ui/src/features/all_project/all_project_screen.tsx +++ b/asp-review-app/ui/src/features/all_project/all_project_screen.tsx @@ -6,9 +6,33 @@ import { HttpRoute, } from "../../core/repository/http_repository"; import { Button } from "antd"; -export const ProjectsPath = '/' +import { Typography } from "antd"; +import { Card } from "antd"; +import { createProjectRoute } from "../create_project/create_project"; +import { useNavigate } from "react-router-dom"; +import { pathAjaxTopologyScreen } from "../topology_ajax_preview/topology_ajax_preview"; +import { pathStabilityScreen } from "../stability_preview/stability_preview"; + +const { Text, Link, Title } = Typography; +function LinkCreateProjectPage() { + const navigate = useNavigate(); + + return ( + { + navigate(createProjectRoute); + }} + > + <> add new project? + + ); +} + +export const ProjectsPath = "/"; export const ProjectScreen: React.FunctionComponent = () => { const [projects, setProjects] = useState>([]); + const navigate = useNavigate(); useEffect(() => { async function fetchData() { @@ -22,18 +46,44 @@ export const ProjectScreen: React.FunctionComponent = () => { fetchData(); }, []); return ( -
-
Projects
+ <> +
+ Projects +
+ {projects.length === 0 ? ( +
+ Not found projects + +
+ +
+
+ ) : ( +
+ )} +
+
{projects.map((el) => { return ( <> -
{el}
- {" "} + +
{el}
+ + + + + +
); })} +
{projects.length === 0 ? <> : }
-
+ ); }; diff --git a/asp-review-app/ui/src/features/create_project/create_project.tsx b/asp-review-app/ui/src/features/create_project/create_project.tsx new file mode 100644 index 0000000..044701f --- /dev/null +++ b/asp-review-app/ui/src/features/create_project/create_project.tsx @@ -0,0 +1,72 @@ +import { Spin, Typography } from "antd"; +import * as React from "react"; +import { useNavigate } from "react-router-dom"; +import { + HttpMethod, + HttpRepository, + HttpRoute, +} from "../../core/repository/http_repository"; +import { pathStabilityScreen } from "../stability_preview/stability_preview"; + +const { Title } = Typography; + +export const createProjectRoute = "/new_project"; + +const UploadButton = () => { + const navigate = useNavigate(); + const [isLoading, setLoading] = React.useState(false); + + const handleImageChange = function (e: React.ChangeEvent) { + const fileList = e.target.files; + + if (!fileList) return; + + let file = fileList[0] as File; + uploadFile(file); + }; + + const uploadFile = async (file: File) => { + if (file) { + const formData = new FormData(); + formData.append("freecad", file, file.name); + setLoading(true); + await HttpRepository.request( + HttpMethod.POST, + HttpRoute.createProject, + formData + ); + setLoading(false); + navigate(pathStabilityScreen) + } + }; + return isLoading ? ( + <> + + + ) : ( + + ); +}; +export default function CreateProject() { + return ( +
+
+ Create new project +
+
+ +
+
+ ); +} diff --git a/asp-review-app/ui/src/features/stability_preview/stability_preview.tsx b/asp-review-app/ui/src/features/stability_preview/stability_preview.tsx new file mode 100644 index 0000000..f85b80b --- /dev/null +++ b/asp-review-app/ui/src/features/stability_preview/stability_preview.tsx @@ -0,0 +1,57 @@ + +import { Button } from 'antd'; +import * as React from 'react'; +import { useParams } from 'react-router-dom'; +import { HttpRepository, HttpMethod, HttpRoute } from '../../core/repository/http_repository'; + + +export const pathStabilityScreen = '/stability/preview/usecase/' + +interface IStabilityCheckResponce { + status: "rejected" | "fulfilled"; + value: undefined | string; + index: number; +} +interface IStability { + status: boolean; + detail: string; +} + +export const StabilityPreviewScreen: React.FunctionComponent = () => { + const id = useParams().id + const [stabilityResult, setStability] = React.useState(null); + React.useEffect(() => { + const stabilityCheck = async () => { + const result = await HttpRepository.jsonRequest>(HttpMethod.GET, '/' + id + '/generation/step-structure.json') + const promises = [] + for (let i = 0; i !== result.length; i++) { + const stabilitySubId = i + 1 + promises.push(HttpRepository.jsonRequest>(HttpMethod.GET, '/' + id + '/generation/stability/' + stabilitySubId + '/geometry.json')) + } + const stabilityCheck = await (await Promise.allSettled(promises)).map((element, index) => { + return { + status: element.status === 'fulfilled' ? true : false, + detail: result[index], + } + }) + setStability(stabilityCheck) + }; + stabilityCheck() + }, []); + return (
+ {stabilityResult != null ? (<> + {stabilityResult.map((el, index) => { + return (
{el.detail}
{el.status ? (<>Sucses) : (<>)}
) + })} + + ) : (
loading
)} + +
); +}; + + diff --git a/asp-review-app/ui/src/features/topology_ajax_preview/topology_ajax_preview.tsx b/asp-review-app/ui/src/features/topology_ajax_preview/topology_ajax_preview.tsx new file mode 100644 index 0000000..a08435f --- /dev/null +++ b/asp-review-app/ui/src/features/topology_ajax_preview/topology_ajax_preview.tsx @@ -0,0 +1,48 @@ + +import * as React from 'react'; +import { useParams } from 'react-router-dom'; +import { HttpRepository, HttpMethod, HttpRoute } from '../../core/repository/http_repository'; + + +export const pathAjaxTopologyScreen = '/topology/adjax/usecase/' +export interface IAdjaxMatrix { + allPars: string[]; + firstDetail: string; + matrix: StringMap; + matrixError: StringMap | null; +} +interface StringMap { [key: string]: string; } + + +export const MatrixTopologyAdjaxScreen: React.FunctionComponent = () => { + const [matrix, setMatrix] = React.useState(null); + const param = useParams().id + React.useEffect(() => { + async function fetchData() { + setMatrix( + await HttpRepository.jsonRequest( + HttpMethod.GET, + '/' + param + '/' + HttpRoute.ajaxMatrix + ) + ); + } + fetchData(); + }, []); + return (
+ {matrix === null ? (<>loaded) : (<> + {matrix.matrixError != null ? (<> + {Object.keys(matrix.matrixError).map((keyName, i) => { + const m = matrix.matrixError as StringMap; + return ( +
+
{m[keyName]}
+
+ ) + })} + ) : (<>Success)} + )} + +
); +}; + + diff --git a/asp-review-app/ui/src/index.tsx b/asp-review-app/ui/src/index.tsx index ddfc042..b340726 100644 --- a/asp-review-app/ui/src/index.tsx +++ b/asp-review-app/ui/src/index.tsx @@ -14,7 +14,10 @@ import { AssemblyPreviewSubsequence, AssemblyPreviewSubsequencePath, } from "./features/assembly_preview_subsequence/assembly_preview_subsequence_screen"; - +import CreateProject, { createProjectRoute } from "./features/create_project/create_project"; +import { pathAjaxTopologyScreen, MatrixTopologyAdjaxScreen } from "./features/topology_ajax_preview/topology_ajax_preview"; +import { pathStabilityScreen, StabilityPreviewScreen } from "./features/stability_preview/stability_preview"; + const rootElement = document.getElementById("root"); const router = createBrowserRouter([ @@ -22,6 +25,10 @@ const router = createBrowserRouter([ path: ProjectsPath, element: , }, + { + path:createProjectRoute, + element: + }, { path: AssemblyPreviewSubsequencePath + ":id", element: , @@ -30,5 +37,14 @@ const router = createBrowserRouter([ path: AssemblyPreviewInsertVectorPath + ":id", element: , }, + { + path: pathAjaxTopologyScreen + ":id", + element: + }, + { + path: pathStabilityScreen + ':id', + element: + } ]); + render(, rootElement); diff --git a/asp-review-app/ui/yarn.lock b/asp-review-app/ui/yarn.lock index de64e8e..c46e755 100644 --- a/asp-review-app/ui/yarn.lock +++ b/asp-review-app/ui/yarn.lock @@ -23,9 +23,9 @@ "@ctrl/tinycolor" "^3.4.0" "@ant-design/cssinjs@^1.9.1": - version "1.9.1" - resolved "https://registry.npmjs.org/@ant-design/cssinjs/-/cssinjs-1.9.1.tgz" - integrity sha512-CZt1vCMs/sY7RoacYuIkZwQmb8Bhp99ReNNE9Y8lnUzik8fmCdKAQA7ecvVOFwmNFdcBHga7ye/XIRrsbkiqWw== + version "1.10.1" + resolved "https://registry.npmjs.org/@ant-design/cssinjs/-/cssinjs-1.10.1.tgz" + integrity sha512-PSoJS8RMzn95ZRg007dJGr6AU0Zim/O+tTN0xmXmh9CkIl4y3wuOr2Zhehaj7s130wPSYDVvahf3DKT50w/Zhw== dependencies: "@babel/runtime" "^7.11.1" "@emotion/hash" "^0.8.0" @@ -217,7 +217,7 @@ dependencies: "@babel/types" "^7.21.0" -"@babel/helper-module-imports@^7.10.4", "@babel/helper-module-imports@^7.18.6", "@babel/helper-module-imports@^7.21.4": +"@babel/helper-module-imports@^7.0.0", "@babel/helper-module-imports@^7.10.4", "@babel/helper-module-imports@^7.18.6", "@babel/helper-module-imports@^7.21.4": version "7.21.4" resolved "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.21.4.tgz" integrity sha512-orajc5T2PsRYUN3ZryCEFeMDYwyw09c/pZeaQEZPH0MpKzSvn3e0uXsDBu3k03VI+9DBiRo+l22BfKTpKwa/Wg== @@ -1101,7 +1101,7 @@ "@babel/parser" "^7.20.7" "@babel/types" "^7.20.7" -"@babel/traverse@^7.20.5", "@babel/traverse@^7.20.7", "@babel/traverse@^7.21.0", "@babel/traverse@^7.21.2", "@babel/traverse@^7.21.4", "@babel/traverse@^7.7.2": +"@babel/traverse@^7.20.5", "@babel/traverse@^7.20.7", "@babel/traverse@^7.21.0", "@babel/traverse@^7.21.2", "@babel/traverse@^7.21.4", "@babel/traverse@^7.4.5", "@babel/traverse@^7.7.2": version "7.21.4" resolved "https://registry.npmjs.org/@babel/traverse/-/traverse-7.21.4.tgz" integrity sha512-eyKrRHKdyZxqDm+fV1iqL9UAHMoIg0nDaGqfIOd8rKH17m5snv7Gn4qgjBoFfLz9APvjFU/ICT00NVCv1Epp8Q== @@ -1279,7 +1279,24 @@ resolved "https://registry.npmjs.org/@emotion/hash/-/hash-0.8.0.tgz" integrity sha512-kBJtf7PH6aWwZ6fka3zQ0p6SBYzx4fl1LoZXE2RrnYST9Xljm7WfKJrU4g/Xr3Beg72MLrp1AWNUmuYJTL7Cow== -"@emotion/unitless@^0.7.5": +"@emotion/is-prop-valid@^1.1.0": + version "1.2.1" + resolved "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-1.2.1.tgz" + integrity sha512-61Mf7Ufx4aDxx1xlDeOm8aFFigGHE4z+0sKCa+IHCeZKiyP9RLD0Mmx7m8b9/Cf37f7NAvQOOJAbQQGVr5uERw== + dependencies: + "@emotion/memoize" "^0.8.1" + +"@emotion/memoize@^0.8.1": + version "0.8.1" + resolved "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.8.1.tgz" + integrity sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA== + +"@emotion/stylis@^0.8.4": + version "0.8.5" + resolved "https://registry.npmjs.org/@emotion/stylis/-/stylis-0.8.5.tgz" + integrity sha512-h6KtPihKFn3T9fuIrwvXXUOwlx3rfUvfZIcP5a6rh8Y7zjE3O06hT5Ss4S/YI1AYhuZ1kjaE/5EaOOI2NqSylQ== + +"@emotion/unitless@^0.7.4", "@emotion/unitless@^0.7.5": version "0.7.5" resolved "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.7.5.tgz" integrity sha512-OWORNpfjMsSSUBVrRBVGECkhWcULOAJz9ZW8uK9qgxD+87M7jHRcvh/A96XXNhXTLmKcoYSQtBEX7lHMO7YRwg== @@ -1685,9 +1702,9 @@ rc-util "^5.27.0" "@rc-component/mini-decimal@^1.0.1": - version "1.0.1" - resolved "https://registry.npmjs.org/@rc-component/mini-decimal/-/mini-decimal-1.0.1.tgz" - integrity sha512-9N8nRk0oKj1qJzANKl+n9eNSMUGsZtjwNuDCiZ/KA+dt1fE3zq5x2XxclRcAbOIXnZcJ53ozP2Pa60gyELXagA== + version "1.1.0" + resolved "https://registry.npmjs.org/@rc-component/mini-decimal/-/mini-decimal-1.1.0.tgz" + integrity sha512-jS4E7T9Li2GuYwI6PyiVXmxTiM6b07rlD9Ge8uGZSCz3WlzcG5ZK7g5bbuKNeZ9pgUuPK/5guV781ujdVpm4HQ== dependencies: "@babel/runtime" "^7.18.0" @@ -1721,9 +1738,9 @@ rc-util "^5.24.4" "@rc-component/trigger@^1.0.4", "@rc-component/trigger@^1.13.0", "@rc-component/trigger@^1.3.6", "@rc-component/trigger@^1.5.0", "@rc-component/trigger@^1.7.0": - version "1.13.3" - resolved "https://registry.npmjs.org/@rc-component/trigger/-/trigger-1.13.3.tgz" - integrity sha512-CA4s8QGj2kagp8dmYRVcSIW5IErw/YBxSeFEsQmt6SB0oaj9pj+akkB6O0S/Y6ww5JrIDu9Bukq89se1oW9F3w== + version "1.13.6" + resolved "https://registry.npmjs.org/@rc-component/trigger/-/trigger-1.13.6.tgz" + integrity sha512-13aF9SrR5XAd+tyV/zja0A2pbrA/zdTCXRBNIsoLp8OmhVOnqiwjP7XZYPulLsH0ioEfvtXR1yI0anJD0/J7PQ== dependencies: "@babel/runtime" "^7.18.3" "@rc-component/portal" "^1.1.0" @@ -1731,7 +1748,7 @@ rc-align "^4.0.0" rc-motion "^2.0.0" rc-resize-observer "^1.3.1" - rc-util "^5.31.1" + rc-util "^5.33.0" "@react-spring/animated@~9.6.1": version "9.6.1" @@ -2286,10 +2303,10 @@ resolved "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz" integrity sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw== -"@types/react-dom@^18.0.0": - version "18.0.11" - resolved "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.0.11.tgz" - integrity sha512-O38bPbI2CWtgw/OoQoY+BRelw7uysmXbWvw3nLWO21H1HSh+GOlqPuXshJfjmpNlKiiSDG9cc1JZAaMmVdcTlw== +"@types/react-dom@^18.0.0", "@types/react-dom@18.0.9": + version "18.0.9" + resolved "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.0.9.tgz" + integrity sha512-qnVvHxASt/H7i+XG1U1xMiY5t+IHcPGUK7TDMDzom08xa7e86eCeKOiLZezwCKVxJn6NEiiy2ekgX8aQssjIKg== dependencies: "@types/react" "*" @@ -2307,10 +2324,10 @@ dependencies: "@types/react" "*" -"@types/react@*", "@types/react@^18.0.0": - version "18.0.32" - resolved "https://registry.npmjs.org/@types/react/-/react-18.0.32.tgz" - integrity sha512-gYGXdtPQ9Cj0w2Fwqg5/ak6BcK3Z15YgjSqtyDizWUfx7mQ8drs0NBUzRRsAdoFVTO8kJ8L2TL8Skm7OFPnLUw== +"@types/react@*", "@types/react@18.0.25": + version "18.0.25" + resolved "https://registry.npmjs.org/@types/react/-/react-18.0.25.tgz" + integrity sha512-xD6c0KDT4m7n9uD4ZHi02lzskaiqcBxf4zi+tXZY98a04wvc0hi/TcCPC2FOESZi51Nd7tlUeOJY8RofL799/g== dependencies: "@types/prop-types" "*" "@types/scheduler" "*" @@ -3142,6 +3159,22 @@ babel-plugin-polyfill-regenerator@^0.4.1: dependencies: "@babel/helper-define-polyfill-provider" "^0.3.3" +"babel-plugin-styled-components@>= 1.12.0": + version "2.1.3" + resolved "https://registry.npmjs.org/babel-plugin-styled-components/-/babel-plugin-styled-components-2.1.3.tgz" + integrity sha512-jBioLwBVHpOMU4NsueH/ADcHrjS0Y/WTpt2eGVmmuSFNEv2DF3XhcMncuZlbbjxQ4vzxg+yEr6E6TNjrIQbsJQ== + dependencies: + "@babel/helper-annotate-as-pure" "^7.18.6" + "@babel/helper-module-imports" "^7.21.4" + babel-plugin-syntax-jsx "^6.18.0" + lodash "^4.17.21" + picomatch "^2.3.1" + +babel-plugin-syntax-jsx@^6.18.0: + version "6.18.0" + resolved "https://registry.npmjs.org/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.18.0.tgz" + integrity sha512-qrPaCSo9c8RHNRHIotaufGbuOBN8rtdC4QrrFFc43vyWCCz7Kl7GL1PGaXtMGQZUXrkCjNEgxDfmAuAabr/rlw== + babel-plugin-transform-react-remove-prop-types@^0.4.24: version "0.4.24" resolved "https://registry.npmjs.org/babel-plugin-transform-react-remove-prop-types/-/babel-plugin-transform-react-remove-prop-types-0.4.24.tgz" @@ -3370,6 +3403,11 @@ camelcase@^6.2.0, camelcase@^6.2.1: resolved "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz" integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== +camelize@^1.0.0: + version "1.0.1" + resolved "https://registry.npmjs.org/camelize/-/camelize-1.0.1.tgz" + integrity sha512-dU+Tx2fsypxTgtLoE36npi3UqcjSSMNYfkqgmoEhtZrraP5VWq0K7FkWVTYa8eMPtnU/G2txVsfdCJTn9uzpuQ== + camera-controls@^2.3.1: version "2.3.4" resolved "https://registry.npmjs.org/camera-controls/-/camera-controls-2.3.4.tgz" @@ -3741,6 +3779,11 @@ css-blank-pseudo@^3.0.3: dependencies: postcss-selector-parser "^6.0.9" +css-color-keywords@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/css-color-keywords/-/css-color-keywords-1.0.0.tgz" + integrity sha512-FyyrDHZKEjXDpNJYvVsV960FiqQyXc/LlYmsxl2BcdMb2WPx0OGRVgTg55rPSyLSNMqP52R9r8geSp7apN3Ofg== + css-declaration-sorter@^6.3.1: version "6.4.0" resolved "https://registry.npmjs.org/css-declaration-sorter/-/css-declaration-sorter-6.4.0.tgz" @@ -3810,6 +3853,15 @@ css-select@^4.1.3: domutils "^2.8.0" nth-check "^2.0.1" +css-to-react-native@^3.0.0: + version "3.2.0" + resolved "https://registry.npmjs.org/css-to-react-native/-/css-to-react-native-3.2.0.tgz" + integrity sha512-e8RKaLXMOFii+02mOlqwjbD00KSEKqblnpO9e++1aXS1fPQOpS1YoqdVHBqPjHNoxeF2mimzVqawm2KCbEdtHQ== + dependencies: + camelize "^1.0.0" + css-color-keywords "^1.0.0" + postcss-value-parser "^4.0.2" + css-tree@^1.1.2: version "1.1.3" resolved "https://registry.npmjs.org/css-tree/-/css-tree-1.1.3.tgz" @@ -5043,11 +5095,6 @@ fs.realpath@^1.0.0: resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz" integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== -fsevents@^2.3.2, fsevents@~2.3.2: - version "2.3.2" - resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz" - integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== - function-bind@^1.1.1: version "1.1.1" resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz" @@ -5297,6 +5344,13 @@ he@^1.2.0: resolved "https://registry.npmjs.org/he/-/he-1.2.0.tgz" integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== +hoist-non-react-statics@^3.0.0: + version "3.3.2" + resolved "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz" + integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw== + dependencies: + react-is "^16.7.0" + hoopy@^0.1.4: version "0.1.4" resolved "https://registry.npmjs.org/hoopy/-/hoopy-0.1.4.tgz" @@ -7868,7 +7922,7 @@ postcss-unique-selectors@^5.1.1: dependencies: postcss-selector-parser "^6.0.5" -postcss-value-parser@^4.0.0, postcss-value-parser@^4.1.0, postcss-value-parser@^4.2.0: +postcss-value-parser@^4.0.0, postcss-value-parser@^4.0.2, postcss-value-parser@^4.1.0, postcss-value-parser@^4.2.0: version "4.2.0" resolved "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz" integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ== @@ -7957,7 +8011,7 @@ prompts@^2.0.1, prompts@^2.4.2: kleur "^3.0.3" sisteransi "^1.0.5" -prop-types@^15.6.0, prop-types@^15.6.2, prop-types@^15.8.1: +prop-types@^15.6.0, prop-types@^15.8.1: version "15.8.1" resolved "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz" integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg== @@ -8120,9 +8174,9 @@ rc-dropdown@~4.1.0: rc-util "^5.17.0" rc-field-form@~1.32.0: - version "1.32.0" - resolved "https://registry.npmjs.org/rc-field-form/-/rc-field-form-1.32.0.tgz" - integrity sha512-vr5pA0/gWiBZf0HKdevQJcWSsAac10Z8Nj1Brs3OOCnExk7l+u8GtsW+4cRSqJLug5fxV11dOGXpxf7+aHT/2A== + version "1.32.2" + resolved "https://registry.npmjs.org/rc-field-form/-/rc-field-form-1.32.2.tgz" + integrity sha512-SzqG1YGyD2P42ztZJ7qoPQp6FV9bD51RUdKGG/5xwybU1wbFdgWTqiMXkS8UR9L4GwXVMKh5PaF2I4EBXd/Rng== dependencies: "@babel/runtime" "^7.18.0" async-validator "^4.1.0" @@ -8204,9 +8258,9 @@ rc-notification@~5.0.4: rc-util "^5.20.1" rc-overflow@^1.0.0, rc-overflow@^1.2.8: - version "1.3.0" - resolved "https://registry.npmjs.org/rc-overflow/-/rc-overflow-1.3.0.tgz" - integrity sha512-p2Qt4SWPTHAYl4oAao1THy669Fm5q8pYBDBHRaFOekCvcdcrgIx0ByXQMEkyPm8wUDX4BK6aARWecvCRc/7CTA== + version "1.3.1" + resolved "https://registry.npmjs.org/rc-overflow/-/rc-overflow-1.3.1.tgz" + integrity sha512-RY0nVBlfP9CkxrpgaLlGzkSoh9JhjJLu6Icqs9E7CW6Ewh9s0peF9OHIex4OhfoPsR92LR0fN6BlCY9Z4VoUtA== dependencies: "@babel/runtime" "^7.11.1" classnames "^2.2.1" @@ -8232,9 +8286,9 @@ rc-picker@~3.7.4: rc-util "^5.30.0" rc-progress@~3.4.1: - version "3.4.1" - resolved "https://registry.npmjs.org/rc-progress/-/rc-progress-3.4.1.tgz" - integrity sha512-eAFDHXlk8aWpoXl0llrenPMt9qKHQXphxcVsnKs0FHC6eCSk1ebJtyaVjJUzKe0233ogiLDeEFK1Uihz3s67hw== + version "3.4.2" + resolved "https://registry.npmjs.org/rc-progress/-/rc-progress-3.4.2.tgz" + integrity sha512-iAGhwWU+tsayP+Jkl9T4+6rHeQTG9kDz8JAHZk4XtQOcYN5fj9H34NXNEdRdZx94VUDHMqCb1yOIvi8eJRh67w== dependencies: "@babel/runtime" "^7.10.1" classnames "^2.2.6" @@ -8270,9 +8324,9 @@ rc-segmented@~2.2.0: rc-util "^5.17.0" rc-select@~14.5.0: - version "14.5.1" - resolved "https://registry.npmjs.org/rc-select/-/rc-select-14.5.1.tgz" - integrity sha512-RQ3yiguq6yJ+kbtip7/6RTq2hOotS/s00nyZL2nxyz5194C6uOtSB8Kgsw3c6ZXII1EDjuJX3zLI1pkxkNWyww== + version "14.5.2" + resolved "https://registry.npmjs.org/rc-select/-/rc-select-14.5.2.tgz" + integrity sha512-Np/lDHvxCnVhVsheQjSV1I/OMJTWJf1n10wq8q1AGy3ytyYLfjNpi6uaz/pmjsbbiSddSWzJnNZCli9LmgBZsA== dependencies: "@babel/runtime" "^7.10.1" "@rc-component/trigger" "^1.5.0" @@ -8365,9 +8419,9 @@ rc-tree-select@~5.9.0: rc-util "^5.16.1" rc-tree@~5.7.0, rc-tree@~5.7.4: - version "5.7.4" - resolved "https://registry.npmjs.org/rc-tree/-/rc-tree-5.7.4.tgz" - integrity sha512-7VfDq4jma+6fvlzfDXvUJ34SaO2EWkcXGBmPgeFmVKsLNNXcKGl4cRAhs6Ts1zqnX994vu/hb3f1dyTjn43RFg== + version "5.7.5" + resolved "https://registry.npmjs.org/rc-tree/-/rc-tree-5.7.5.tgz" + integrity sha512-iyM60rUdJh+KinxSjtZ40eox/DdjIwCUM4oBUoOLyrSwXsaoVZtpcVgWwZExjgHp4MSsn3FhVSntO/5c3aMbSQ== dependencies: "@babel/runtime" "^7.10.1" classnames "2.x" @@ -8395,10 +8449,10 @@ rc-upload@~4.3.0: classnames "^2.2.5" rc-util "^5.2.0" -rc-util@^5.0.1, rc-util@^5.0.6, rc-util@^5.15.0, rc-util@^5.16.0, rc-util@^5.16.1, rc-util@^5.17.0, rc-util@^5.18.1, rc-util@^5.19.2, rc-util@^5.2.0, rc-util@^5.20.1, rc-util@^5.21.0, rc-util@^5.21.2, rc-util@^5.22.5, rc-util@^5.24.4, rc-util@^5.25.2, rc-util@^5.26.0, rc-util@^5.27.0, rc-util@^5.27.1, rc-util@^5.28.0, rc-util@^5.30.0, rc-util@^5.31.1, rc-util@^5.32.0, rc-util@^5.32.2, rc-util@^5.6.1: - version "5.32.4" - resolved "https://registry.npmjs.org/rc-util/-/rc-util-5.32.4.tgz" - integrity sha512-LRQpfPjtLbN9BrNgU/evbQrhTLfHepJPSKbhHF2Nm1cnNeZkSqXCKDTDPjMXa1VavcnJA1iP39O8PB0+Rc216Q== +rc-util@^5.0.1, rc-util@^5.0.6, rc-util@^5.15.0, rc-util@^5.16.0, rc-util@^5.16.1, rc-util@^5.17.0, rc-util@^5.18.1, rc-util@^5.19.2, rc-util@^5.2.0, rc-util@^5.20.1, rc-util@^5.21.0, rc-util@^5.21.2, rc-util@^5.22.5, rc-util@^5.24.4, rc-util@^5.25.2, rc-util@^5.26.0, rc-util@^5.27.0, rc-util@^5.27.1, rc-util@^5.28.0, rc-util@^5.30.0, rc-util@^5.31.1, rc-util@^5.32.0, rc-util@^5.32.2, rc-util@^5.33.0, rc-util@^5.6.1: + version "5.33.1" + resolved "https://registry.npmjs.org/rc-util/-/rc-util-5.33.1.tgz" + integrity sha512-oMs2OIV/2lUCF8nllevzLccneyxAzdSOaHSs5y91qOLdqaLbIMsuL49C6/DhF/WKMqiAKEKGdVk2F1sB5HQe9A== dependencies: "@babel/runtime" "^7.18.3" react-is "^16.12.0" @@ -8462,15 +8516,13 @@ react-dev-utils@^12.0.1: strip-ansi "^6.0.1" text-table "^0.2.0" -react-dom@*, react-dom@^16.12.0, react-dom@^18.0.0, react-dom@>=16.0.0, react-dom@>=16.11.0, react-dom@>=16.13, react-dom@>=16.8, react-dom@>=16.9.0, react-dom@>=17.0, react-dom@>=18.0: - version "16.14.0" - resolved "https://registry.npmjs.org/react-dom/-/react-dom-16.14.0.tgz" - integrity sha512-1gCeQXDLoIqMgqD3IO2Ah9bnf0w9kzhwN5q4FGnHZ67hBm9yePzB5JJAIQCc8x3pFnNlwFq4RidZggNAAkzWWw== +react-dom@*, "react-dom@^16.8.0 || ^17.0.0 || ^18.0.0", "react-dom@^16.8.6 || ^17 || ^18", react-dom@^18.0.0, "react-dom@>= 16.8.0", react-dom@>=16.0.0, react-dom@>=16.11.0, react-dom@>=16.13, react-dom@>=16.8, react-dom@>=16.9.0, react-dom@>=17.0, react-dom@>=18.0, react-dom@18.0.0: + version "18.0.0" + resolved "https://registry.npmjs.org/react-dom/-/react-dom-18.0.0.tgz" + integrity sha512-XqX7uzmFo0pUceWFCt7Gff6IyIMzFUn7QMZrbrQfGxtaxXZIcGQzoNpRLE3fQLnS4XzLLPMZX2T9TRcSrasicw== dependencies: loose-envify "^1.1.0" - object-assign "^4.1.1" - prop-types "^15.6.2" - scheduler "^0.19.1" + scheduler "^0.21.0" react-error-overlay@^6.0.11: version "6.0.11" @@ -8495,7 +8547,12 @@ react-is@^16.13.1: resolved "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz" integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== -react-is@^17.0.1: +react-is@^16.7.0: + version "16.13.1" + resolved "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz" + integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== + +react-is@^17.0.1, "react-is@>= 16.8.0": version "17.0.2" resolved "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz" integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== @@ -8552,14 +8609,12 @@ react-use-measure@^2.1.1: dependencies: debounce "^1.2.1" -react@*, "react@^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0", react@^16.12.0, react@^16.14.0, "react@^16.8.0 || ^17 || ^18", "react@^16.8.0 || ^17.0.0 || ^18.0.0", react@^18.0.0, "react@>= 16.8.0", react@>=16.0.0, react@>=16.11.0, react@>=16.13, react@>=16.8, react@>=16.9.0, react@>=17.0, react@>=18.0: - version "16.14.0" - resolved "https://registry.npmjs.org/react/-/react-16.14.0.tgz" - integrity sha512-0X2CImDkJGApiAlcf0ODKIneSwBPhqJawOa5wCtKbu7ZECrmS26NvtSILynQ66cgkT/RJ4LidJOc3bUESwmU8g== +react@*, "react@^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0", "react@^16.8.0 || ^17.0.0 || ^18.0.0", "react@^16.8.0 || ^17 || ^18", "react@^16.8.0 || ^17.0.0 || ^18.0.0", "react@^16.8.6 || ^17 || ^18", react@^18.0.0, "react@>= 16.8.0", react@>=16.0.0, react@>=16.11.0, react@>=16.13, react@>=16.8, react@>=16.9.0, react@>=17.0, react@>=18.0, react@18.0.0: + version "18.0.0" + resolved "https://registry.npmjs.org/react/-/react-18.0.0.tgz" + integrity sha512-x+VL6wbT4JRVPm7EGxXhZ8w8LTROaxPXOqhlGyVSrv0sB1jkyFGgXxJ8LVoPRLvPR6/CIZGFmfzqUa2NYeMr2A== dependencies: loose-envify "^1.1.0" - object-assign "^4.1.1" - prop-types "^15.6.2" read-cache@^1.0.0: version "1.0.0" @@ -8766,6 +8821,42 @@ resolve@^2.0.0-next.4: path-parse "^1.0.7" supports-preserve-symlinks-flag "^1.0.0" +rete-area-plugin@^2.0.0-beta.12, rete-area-plugin@2.0.0-beta.12: + version "2.0.0-beta.12" + resolved "https://registry.npmjs.org/rete-area-plugin/-/rete-area-plugin-2.0.0-beta.12.tgz" + integrity sha512-F4JLAmCIKCrPr+HinR651cHfyocALZsF7ORRdOXTBMbsyvlRn0KsOz8HsR8t9+AQbcMb45YXFKO+7QG4WvZQ6w== + dependencies: + "@babel/runtime" "^7.21.0" + +rete-connection-plugin@2.0.0-beta.16: + version "2.0.0-beta.16" + resolved "https://registry.npmjs.org/rete-connection-plugin/-/rete-connection-plugin-2.0.0-beta.16.tgz" + integrity sha512-jniCW/Mt4gPey46eK9or5aguHf8DSbSZa7fUzzRxpnnmO3MpMXoDj8AKjfoKSR24PXK3Xz1prjAg8OEP7YXRDQ== + dependencies: + "@babel/runtime" "^7.21.0" + +rete-react-render-plugin@2.0.0-beta.22: + version "2.0.0-beta.22" + resolved "https://registry.npmjs.org/rete-react-render-plugin/-/rete-react-render-plugin-2.0.0-beta.22.tgz" + integrity sha512-Tcqk6sQMqD8p6+bssarNczZT+MnLv9M1WngmZrfsJ36C1jFckR2A1rmJhqSmXiIE00wcmvBeXblKTHqdFln/Kw== + dependencies: + "@babel/runtime" "^7.21.0" + usehooks-ts "^2.9.1" + +rete-render-utils@^2.0.0-beta.12, rete-render-utils@2.0.0-beta.12: + version "2.0.0-beta.12" + resolved "https://registry.npmjs.org/rete-render-utils/-/rete-render-utils-2.0.0-beta.12.tgz" + integrity sha512-aRXyGQbF9Y9zIg/TuXFXrz+AVj74FLGGONdF/12okPqwm30aUXA3YakdHONfiaxRi/Ibvmrq7nLI+3wU64K4Xw== + dependencies: + "@babel/runtime" "^7.21.0" + +rete@^2.0.0-beta.9, rete@2.0.0-beta.9: + version "2.0.0-beta.9" + resolved "https://registry.npmjs.org/rete/-/rete-2.0.0-beta.9.tgz" + integrity sha512-tmQk0UIjG2qmCamT58Kg8kQQq30/Nal1zr2uqX4mH2L9rZKCUBAL2dWZ160FoRbfTzWr0oFP/7PYhWrYwhkWDA== + dependencies: + "@babel/runtime" "^7.21.0" + retry@^0.13.1: version "0.13.1" resolved "https://registry.npmjs.org/retry/-/retry-0.13.1.tgz" @@ -8861,14 +8952,6 @@ saxes@^5.0.1: dependencies: xmlchars "^2.2.0" -scheduler@^0.19.1: - version "0.19.1" - resolved "https://registry.npmjs.org/scheduler/-/scheduler-0.19.1.tgz" - integrity sha512-n/zwRWRYSUj0/3g/otKDRPMh6qv2SYMWNq85IEa8iZyAv8od9zDYpGSnpBEjNgcMNq6Scbu5KfIPxNF72R/2EA== - dependencies: - loose-envify "^1.1.0" - object-assign "^4.1.1" - scheduler@^0.21.0: version "0.21.0" resolved "https://registry.npmjs.org/scheduler/-/scheduler-0.21.0.tgz" @@ -9025,6 +9108,11 @@ setprototypeof@1.2.0: resolved "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz" integrity sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw== +shallowequal@^1.1.0: + version "1.1.0" + resolved "https://registry.npmjs.org/shallowequal/-/shallowequal-1.1.0.tgz" + integrity sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ== + shebang-command@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz" @@ -9373,6 +9461,22 @@ style-loader@^3.3.1: resolved "https://registry.npmjs.org/style-loader/-/style-loader-3.3.2.tgz" integrity sha512-RHs/vcrKdQK8wZliteNK4NKzxvLBzpuHMqYmUVWeKa6MkaIQ97ZTOS0b+zapZhy6GcrgWnvWYCMHRirC3FsUmw== +styled-components@^5.3.6, "styled-components@>= 2": + version "5.3.11" + resolved "https://registry.npmjs.org/styled-components/-/styled-components-5.3.11.tgz" + integrity sha512-uuzIIfnVkagcVHv9nE0VPlHPSCmXIUGKfJ42LNjxCCTDTL5sgnJ8Z7GZBq0EnLYGln77tPpEpExt2+qa+cZqSw== + dependencies: + "@babel/helper-module-imports" "^7.0.0" + "@babel/traverse" "^7.4.5" + "@emotion/is-prop-valid" "^1.1.0" + "@emotion/stylis" "^0.8.4" + "@emotion/unitless" "^0.7.4" + babel-plugin-styled-components ">= 1.12.0" + css-to-react-native "^3.0.0" + hoist-non-react-statics "^3.0.0" + shallowequal "^1.1.0" + supports-color "^5.5.0" + stylehacks@^5.1.1: version "5.1.1" resolved "https://registry.npmjs.org/stylehacks/-/stylehacks-5.1.1.tgz" @@ -9405,6 +9509,13 @@ supports-color@^5.3.0: dependencies: has-flag "^3.0.0" +supports-color@^5.5.0: + version "5.5.0" + resolved "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz" + integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== + dependencies: + has-flag "^3.0.0" + supports-color@^7.0.0, supports-color@^7.1.0: version "7.2.0" resolved "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz" @@ -9897,6 +10008,11 @@ url-parse@^1.5.3: querystringify "^2.1.1" requires-port "^1.0.0" +usehooks-ts@^2.9.1: + version "2.9.1" + resolved "https://registry.npmjs.org/usehooks-ts/-/usehooks-ts-2.9.1.tgz" + integrity sha512-2FAuSIGHlY+apM9FVlj8/oNhd+1y+Uwv5QNkMQz1oSfdHk4PXo1qoCw9I5M7j0vpH8CSWFJwXbVPeYDjLCx9PA== + util-deprecate@^1.0.1, util-deprecate@^1.0.2, util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" diff --git a/asp/.gitignore b/asp/.gitignore new file mode 100644 index 0000000..c585e19 --- /dev/null +++ b/asp/.gitignore @@ -0,0 +1 @@ +out \ No newline at end of file diff --git a/asp/main.py b/asp/main.py index 893c97d..48240cd 100644 --- a/asp/main.py +++ b/asp/main.py @@ -1,17 +1,14 @@ import argparse import shutil from helper.fs import FS -from src.usecases.stability_check_usecase import StabilityCheckUseCase from src.usecases.urdf_sub_assembly_usecase import UrdfSubAssemblyUseCase -from src.usecases.sdf_generate_world_usecase import SdfGenerateWorldUseCase +# from src.usecases.sdf_generate_world_usecase import SdfGenerateWorldUseCase from src.model.sdf_geometry import GeometryModel from src.usecases.sdf_sub_assembly_usecase import SdfSubAssemblyUseCase import os -# python3 main.py --generationFolder /Users/idontsudo/robo/Cube3/ --outPath /Users/idontsudo/robo/ --world true --format 'urdf' --stabilityCheck 'true' -# python3 main.py --generationFolder /Users/idontsudo/robo/Cube3/ --outPath /Users/idontsudo/robo/ --world true --format 'sdf' if __name__ == "__main__": parser = argparse.ArgumentParser() @@ -19,8 +16,6 @@ if __name__ == "__main__": parser.add_argument('--outPath', help='save SDF path') parser.add_argument('--world', help='adding sdf world') parser.add_argument('--format', help='urdf,sdf,mujoco') - parser.add_argument('--stabilityCheck', - help='do i need to check the stability?') args = parser.parse_args() if args.generationFolder == None or args.outPath == None: @@ -44,13 +39,10 @@ if __name__ == "__main__": generationFolder=args.generationFolder, outPath=args.outPath ) - if (args.format == 'urdf' and args.stabilityCheck != None): + if (args.format == 'urdf'): UrdfSubAssemblyUseCase().call( geometryModels=geometryModels, assembly=assemblyStructure, world=args.world, generationFolder=args.generationFolder, outPath=args.outPath ) - StabilityCheckUseCase().call( - args.outPath - ) diff --git a/asp/src/usecases/formatter_usecase.py b/asp/src/usecases/formatter_usecase.py index fa0de3f..9efa2e8 100644 --- a/asp/src/usecases/formatter_usecase.py +++ b/asp/src/usecases/formatter_usecase.py @@ -1,11 +1,10 @@ from src.model.enum import Enum -import xmlformatter from helper.fs import FS - +import xmlformatter class FormatterUseCase: def call(outPath: str, format: str): - formatter = xmlformatter.Formatter( + formatter = xmlformatter( indent="1", indent_char="\t", encoding_output="ISO-8859-1", preserve=["literal"]) files = FS.readFilesTypeFolder( diff --git a/asp/src/usecases/stability_check_usecase.py b/asp/src/usecases/stability_check_usecase.py deleted file mode 100644 index c55b092..0000000 --- a/asp/src/usecases/stability_check_usecase.py +++ /dev/null @@ -1,36 +0,0 @@ -import numpy as np -import pybullet as p -import time -import pybullet_data -from helper.fs import FS -from src.usecases.urdf_sub_assembly_usecase import URDF_GENERATOR_FILE -import json - -from src.model.enum import Enum - - -class StabilityCheckUseCase: - def call(self, outPath: str): - dirPath = outPath + Enum.folderPath - DURATION = 10000 - asm = json.loads(FS.readFile(dirPath + URDF_GENERATOR_FILE)) - inc = 0 - for el in asm['asm2']: - FS.writeFile(data=el, filePath=dirPath, - fileName=str(inc) + '.urdf') - inc += 1 - assemblyURDFS = list( - map(lambda el: dirPath+el, FS.readFilesTypeFolder(dirPath, '.urdf'))) - physicsClient = p.connect(p.GUI) - - p.setGravity(0, 0, -10) - - for el in assemblyURDFS: - p.loadURDF(el) - - - for i in range(DURATION): - p.stepSimulation() - time.sleep(1./240.) - - p.disconnect() diff --git a/asp/src/usecases/urdf_sub_assembly_usecase.py b/asp/src/usecases/urdf_sub_assembly_usecase.py index 0c82827..907662e 100644 --- a/asp/src/usecases/urdf_sub_assembly_usecase.py +++ b/asp/src/usecases/urdf_sub_assembly_usecase.py @@ -5,6 +5,7 @@ from src.model.asm import Assembly from src.model.sdf_geometry import GeometryModel from helper.fs import filterModels, listGetFirstValue import json +import re def toUrdf(el: GeometryModel): @@ -21,6 +22,7 @@ class UrdfSubAssemblyUseCase(Assembly): generateSubAssemblyModels = self.generateSubAssembly(assembly) inc = 0 for key, value in generateSubAssemblyModels.items(): + keyAsm = int(re.findall(r'\d', key)[0]) inc += 1 if value['assembly'].__len__() != 0: model: Optional[GeometryModel] = listGetFirstValue( @@ -32,11 +34,9 @@ class UrdfSubAssemblyUseCase(Assembly): geometryModels, value['assembly']))) urdfs.append(listGetFirstValue( geometryModels, None, lambda x: x.name == value['part']) .toUrdf()) - asm[key] = urdfs + asm[keyAsm] = urdfs self.copy(generationFolder=generationFolder, format='/sdf', outPath=outPath) - FS.writeFile(data=json.dumps(asm), fileName=URDF_GENERATOR_FILE, filePath=dirPath) - # for el in asm.keys(): diff --git a/cad_generation/env.json b/cad_generation/env.json new file mode 100644 index 0000000..3945e7a --- /dev/null +++ b/cad_generation/env.json @@ -0,0 +1,6 @@ +{ + "doc": "/home/idontsudo/t/framework/asp-review-app/server/public/cubes/cubes.FCStd", + "out": "/home/idontsudo/t/framework/cad_generation", + "resultURL": "http://localhost:3002/assembly/save/out", + "projectId": "cubes" +} \ No newline at end of file diff --git a/cad_generation/helper/fs.py b/cad_generation/helper/fs.py new file mode 100644 index 0000000..3026bb4 --- /dev/null +++ b/cad_generation/helper/fs.py @@ -0,0 +1,15 @@ +import os +import json + + +class FS: + def readJSON(path: str): + return json.loads((open(path)).read()) + + def writeFile(data, filePath, fileName): + file_to_open = filePath + fileName + + f = open(file_to_open, 'w', encoding='utf-8', + errors='ignore') + f.write(data) + f.close() diff --git a/cad_generation/helper/is_solid.py b/cad_generation/helper/is_solid.py new file mode 100644 index 0000000..431c814 --- /dev/null +++ b/cad_generation/helper/is_solid.py @@ -0,0 +1,18 @@ +import FreeCAD + + +def is_object_solid(obj): + """If obj is solid return True""" + if not isinstance(obj, FreeCAD.DocumentObject): + return False + + if not hasattr(obj, 'Shape'): + return False + + if not hasattr(obj.Shape, 'Solids'): + return False + + if len(obj.Shape.Solids) == 0: + return False + + return True diff --git a/cad_generation/main.py b/cad_generation/main.py new file mode 100644 index 0000000..83ddba7 --- /dev/null +++ b/cad_generation/main.py @@ -0,0 +1,19 @@ +import requests +import FreeCAD as App +from helper.fs import FS +from scenarios.robossembler_freecad_export_scenario import RobossemblerFreeCadExportScenario +import shutil +import os +import FreeCADGui as Gui + + +def main(): + env = FS.readJSON('./env.json') + App.openDocument(env.get('doc')) + RobossemblerFreeCadExportScenario().call(env.get('out')) + # requests.post(url=env.get('resultURL'), files={'zip': open(env.get('out') + '/' + 'generation.zip', "rb"), 'id':env.get('projectId')}) + # os.remove('./generation.zip') + App.closeDocument(App.ActiveDocument.Name) + freecadQTWindow = Gui.getMainWindow() + freecadQTWindow.close() +main() diff --git a/cad_generation/model/files_generator.py b/cad_generation/model/files_generator.py new file mode 100644 index 0000000..68b4a0b --- /dev/null +++ b/cad_generation/model/files_generator.py @@ -0,0 +1,13 @@ +from enum import Enum + + +class FilesGenerator(Enum): + DETAIL = 'detail.json' + ASSEMBLY = 'assembly.json' + + +class FolderGenerator(Enum): + MESHES = 'meshes' + ASSETS = 'assets' + SDF = 'sdf' + ASSEMBlY = 'assembly' diff --git a/cad_generation/model/geometry_part.py b/cad_generation/model/geometry_part.py new file mode 100644 index 0000000..f63f055 --- /dev/null +++ b/cad_generation/model/geometry_part.py @@ -0,0 +1,86 @@ +from typing import Any, TypeVar, Type, cast + + +T = TypeVar("T") + + +def from_float(x: Any) -> float: + assert isinstance(x, (float, int)) and not isinstance(x, bool) + return float(x) + + +def to_float(x: Any) -> float: + assert isinstance(x, float) + return x + + +def to_class(c: Type[T], x: Any) -> dict: + assert isinstance(x, c) + return cast(Any, x).to_dict() + + +class Axis: + x: float + y: float + z: float + + def __init__(self, x: float, y: float, z: float) -> None: + self.x = x + self.y = y + self.z = z + + @staticmethod + def from_dict(obj: Any) -> 'Axis': + assert isinstance(obj, dict) + x = from_float(obj.get("x")) + y = from_float(obj.get("y")) + z = from_float(obj.get("z")) + return Axis(x, y, z) + + def to_dict(self) -> dict: + result: dict = {} + result["x"] = to_float(self.x) + result["y"] = to_float(self.y) + result["z"] = to_float(self.z) + return result + + +class GeometryPart: + euler: Axis + position: Axis + rotation: Axis + center: Axis + + def __init__(self, euler: Axis, position: Axis, rotation: Axis, center: Axis) -> None: + self.euler = euler + self.position = position + self.rotation = rotation + self.center = center + + @staticmethod + def from_dict(obj: Any) -> 'GeometryPart': + assert isinstance(obj, dict) + euler = Axis.from_dict(obj.get("euler")) + position = Axis.from_dict(obj.get("position")) + rotation = Axis.from_dict(obj.get("rotation")) + center = Axis.from_dict(obj.get("center")) + return GeometryPart(euler, position, rotation, center) + + def to_dict(self) -> dict: + result: dict = {} + result["euler"] = to_class(Axis, self.euler) + result["position"] = to_class(Axis, self.position) + result["rotation"] = to_class(Axis, self.rotation) + result["center"] = to_class(Axis, self.center) + return result + + def toJson(self) -> str: + return str(self.to_dict()).replace('\'', '"') + + +def geometry_part_from_dict(s: Any) -> GeometryPart: + return GeometryPart.from_dict(s) + + +def geometry_part_to_dict(x: GeometryPart) -> Any: + return to_class(GeometryPart, x) diff --git a/cad_generation/model/join_mesh_model.py b/cad_generation/model/join_mesh_model.py new file mode 100644 index 0000000..52ca96b --- /dev/null +++ b/cad_generation/model/join_mesh_model.py @@ -0,0 +1,33 @@ +import FreeCAD +import Mesh +import FreeCAD as App +from model.mesh_part_model import MeshPartModel + + +class JoinMeshModel: + id = None + mesh = None + + def __init__(self, meshesPartModels: list['MeshPartModel']) -> None: + meshes = [] + import Mesh + from random import randrange + for el in meshesPartModels: + meshes.append(el.mesh.Mesh) + + self.id = 'MergedMesh' + str(randrange(1000000)) + document = App.ActiveDocument + merged_mesh = Mesh.Mesh() + for el in meshes: + merged_mesh.addMesh(el) + + new_obj = App.activeDocument().addObject("Mesh::Feature", self.id) + new_obj.Mesh = merged_mesh + new_obj.ViewObject.DisplayMode = "Flat Lines" # Set display mode to flat lines + self.mesh = new_obj + + def remove(self): + try: + App.ActiveDocument.removeObject(self.id) + except Exception as e: + print(e) diff --git a/cad_generation/model/mesh_part_model.py b/cad_generation/model/mesh_part_model.py new file mode 100644 index 0000000..dc77871 --- /dev/null +++ b/cad_generation/model/mesh_part_model.py @@ -0,0 +1,32 @@ +import FreeCAD as App +import uuid +import Mesh +import Part +# import PartGui +import MeshPart + + +class MeshPartModel: + id = None + mesh = None + + def __init__(self, part) -> None: + try: + from random import randrange + self.id = 'mesh' + str(randrange(1000000)) + document = App.ActiveDocument + mesh = document.addObject("Mesh::Feature", self.id) + shape = Part.getShape(part, "") + mesh.Mesh = MeshPart.meshFromShape( + Shape=shape, LinearDeflection=20, AngularDeflection=0.1, Relative=False) + mesh.Label = self.id + self.mesh = mesh + except Exception as e: + print(e) + pass + + def remove(self): + try: + App.ActiveDocument.removeObject(self.mesh.Label) + except Exception as e: + print(e) diff --git a/cad_generation/model/sdf_geometry_model.py b/cad_generation/model/sdf_geometry_model.py new file mode 100644 index 0000000..dca815d --- /dev/null +++ b/cad_generation/model/sdf_geometry_model.py @@ -0,0 +1,107 @@ +import json + + +def from_str(x): + assert isinstance(x, str) + return x + + +def from_none(x): + assert x is None + return x + + +def from_union(fs, x): + for f in fs: + try: + return f(x) + except: + pass + assert False + + +def to_class(c, x): + assert isinstance(x, c) + return x.to_dict() + + +class SdfGeometryModel: + def __init__(self, name, ixx, ixy, ixz, iyy, izz, massSDF, posX, posY, posZ, eulerX, eulerY, eulerZ, iyz, stl, friction): + self.name = name + self.ixx = ixx + self.ixy = ixy + self.ixz = ixz + self.iyy = iyy + self.izz = izz + self.massSDF = massSDF + self.posX = posX + self.posY = posY + self.posZ = posZ + self.eulerX = eulerX + self.eulerY = eulerY + self.eulerZ = eulerZ + self.iyz = iyz + self.stl = stl + self.friction = friction + + @staticmethod + def from_dict(obj): + assert isinstance(obj, dict) + name = from_union([from_str, from_none], obj.get("name")) + ixx = from_union([from_str, from_none], obj.get("ixx")) + ixy = from_union([from_str, from_none], obj.get("ixy")) + ixz = from_union([from_str, from_none], obj.get("ixz")) + iyy = from_union([from_str, from_none], obj.get("iyy")) + izz = from_union([from_str, from_none], obj.get("izz")) + massSDF = from_union([from_str, from_none], obj.get("massSDF")) + posX = from_union([from_str, from_none], obj.get("posX")) + posY = from_union([from_str, from_none], obj.get("posY")) + posZ = from_union([from_str, from_none], obj.get("posZ")) + eulerX = from_union([from_str, from_none], obj.get("eulerX")) + eulerY = from_union([from_str, from_none], obj.get("eulerY")) + eulerZ = from_union([from_str, from_none], obj.get("eulerZ")) + iyz = from_union([from_str, from_none], obj.get("iyz")) + stl = from_union([from_str, from_none], obj.get("stl") ) + friction = from_union([from_str, from_none], obj.get("friction")) + return SdfGeometryModel(name, ixx, ixy, ixz, iyy, izz, massSDF, posX, posY, posZ, eulerX, eulerY, eulerZ, iyz,stl,friction) + + def to_dict(self): + result = {} + if self.name is not None: + result["name"] = from_union([from_str, from_none], self.name) + if self.ixx is not None: + result["ixx"] = from_union([from_str, from_none], self.ixx) + if self.ixy is not None: + result["ixy"] = from_union([from_str, from_none], self.ixy) + if self.ixz is not None: + result["ixz"] = from_union([from_str, from_none], self.ixz) + if self.iyy is not None: + result["iyy"] = from_union([from_str, from_none], self.iyy) + if self.izz is not None: + result["izz"] = from_union([from_str, from_none], self.izz) + if self.massSDF is not None: + result["massSDF"] = from_union([from_str, from_none], self.massSDF) + if self.posX is not None: + result["posX"] = from_union([from_str, from_none], self.posX) + if self.posY is not None: + result["posY"] = from_union([from_str, from_none], self.posY) + if self.posZ is not None: + result["posZ"] = from_union([from_str, from_none], self.posZ) + if self.eulerX is not None: + result["eulerX"] = from_union([from_str, from_none], self.eulerX) + if self.eulerY is not None: + result["eulerY"] = from_union([from_str, from_none], self.eulerY) + if self.eulerZ is not None: + result["eulerZ"] = from_union([from_str, from_none], self.eulerZ) + if self.iyz is not None: + result["iyz"] = from_union([from_str, from_none], self.iyz) + if self.stl is not None: + result["stl"] = from_union([from_str, from_none], self.stl) + if self.friction is not None: + result["friction"] = from_union([from_str, from_none], self.eulerZ) + return result + + def toJSON(self) -> str: + return str(self.to_dict()).replace('\'', '"') + + \ No newline at end of file diff --git a/cad_generation/model/simple_copy_part_model.py b/cad_generation/model/simple_copy_part_model.py new file mode 100644 index 0000000..05c54f0 --- /dev/null +++ b/cad_generation/model/simple_copy_part_model.py @@ -0,0 +1,30 @@ +import FreeCAD as App +import Part + + +class SimpleCopyPartModel: + id = None + copyLink = None + label = None + part = None + + def getPart(self): + return self.part + + def __init__(self, part) -> None: + try: + from random import randrange + self.id = str(randrange(1000000)) + childObj = part + __shape = Part.getShape( + childObj, '', needSubElement=False, refine=False) + obj = App.ActiveDocument.addObject('Part::Feature', self.id) + obj.Shape = __shape + self.part = obj + self.label = obj.Label + App.ActiveDocument.recompute() + except Exception as e: + print(e) + + def remove(self): + App.ActiveDocument.removeObject(self.label) diff --git a/cad_generation/scenarios/robossembler_freecad_export_scenario.py b/cad_generation/scenarios/robossembler_freecad_export_scenario.py new file mode 100644 index 0000000..c834efb --- /dev/null +++ b/cad_generation/scenarios/robossembler_freecad_export_scenario.py @@ -0,0 +1,54 @@ + +from usecases.export_assembly_them_all_usecase import ExportAssemblyThemAllUseCase +import FreeCAD + +from usecases.export_usecase import EXPORT_TYPES, ExportUseCase +from usecases.get_sdf_geometry_usecase import SdfGeometryUseCase +from usecases.assembly_parse_usecase import AssemblyParseUseCase +from usecases.geometry_usecase import GeometryUseCase +from model.geometry_part import GeometryPart +from model.files_generator import FolderGenerator +from helper.fs import FS +import os +# import ImportGui +import shutil + + +class RobossemblerFreeCadExportScenario: + + def call(self, path): + + + directory = path + '/' + 'generation' + if os.path.exists(directory): + shutil.rmtree(directory) + if not os.path.exists(directory): + os.makedirs(directory) + + __objs__ = FreeCAD.ActiveDocument.RootObjects + directoryExport = directory + '/' + os.makedirs(directoryExport + FolderGenerator.ASSETS.value) + + os.makedirs(directoryExport + FolderGenerator.SDF.value) + os.makedirs(directoryExport + FolderGenerator.SDF.value + '/' + FolderGenerator.MESHES.value) + os.makedirs(directoryExport + FolderGenerator.ASSEMBlY.value) + f = open(directory + "/step-structure.json", "w") + f.write(AssemblyParseUseCase().toJson()) + f.close() + self.geometry(directory) + ExportAssemblyThemAllUseCase().call(directoryExport) + + shutil.make_archive(directory, 'zip', directory) + + shutil.rmtree(directory) + return True + + def geometry(self, outPutsPath: str): + exportUseCase = ExportUseCase.call(outPutsPath,EXPORT_TYPES.OBJ) + for el in SdfGeometryUseCase().call(exportUseCase): + FS.writeFile(el.toJSON(), outPutsPath + '/' + FolderGenerator.ASSETS.value + '/', el.name + '.json',) + + + + + \ No newline at end of file diff --git a/cad_generation/usecases/asm4parser_usecase.py b/cad_generation/usecases/asm4parser_usecase.py new file mode 100644 index 0000000..f732d1b --- /dev/null +++ b/cad_generation/usecases/asm4parser_usecase.py @@ -0,0 +1,53 @@ +import FreeCAD as App + +class Asm4StructureParseUseCase: + _parts = [] + _label = [] + + def getSubPartsLabel(self, group): + groupLabel = [] + for el in group: + if str(el) == '': + groupLabel.append(el.Label) + return groupLabel + + def parseLabel(self, nextGroup, label, level=2, nextGroupParse=0): + if nextGroup.__len__() == nextGroupParse: + return + else: + groupParts = [] + + for el in nextGroup: + if str(el) == '': + groupParts.append(el) + + for el in groupParts: + if str(el) == '': + label.append({ + "level": level, + "attachedTo": el.AttachedTo.split('#'), + "label": el.Label, + "axis": self.getSubPartsLabel(el.Group) + }) + + def initParse(self): + + model = App.ActiveDocument.RootObjects[1] + self._label.append({ + "level": 1, + "attachedTo": "Parent Assembly", + "label": model.Label, + "axis": self.getSubPartsLabel(model.Group) + }) + for parent in model.Group: + if str(parent) == '': + self._label.append({ + "level": 1, + "attachedTo": parent.AttachedTo.split('#'), + "label": parent.Label, + "axis": self.getSubPartsLabel(parent.Group) + }) + print(self._label) + + + \ No newline at end of file diff --git a/cad_generation/usecases/assembly_parse_usecase.py b/cad_generation/usecases/assembly_parse_usecase.py new file mode 100644 index 0000000..e3b4e0d --- /dev/null +++ b/cad_generation/usecases/assembly_parse_usecase.py @@ -0,0 +1,58 @@ +import FreeCAD as App +def is_object_solid(obj): + """If obj is solid return True""" + if not isinstance(obj, App.DocumentObject): + return False + if hasattr(obj, 'Group'): + return False + + if not hasattr(obj, 'Shape'): + return False + # if not hasattr(obj.Shape, 'Mass'): + # return False + if not hasattr(obj.Shape, 'Solids'): + return False + + if len(obj.Shape.Solids) == 0: + return False + + return True + + +class AssemblyParseUseCase: + _parts = [] + + _asm = [] + + def getAsm(self): + return self._asm + + def __init__(self) -> None: + if (self._asm.__len__() == 0): + self.initParse() + pass + + def initParse(self): + for el in App.ActiveDocument.Objects: + if (is_object_solid(el)): + self._asm.append(el.Label) + + def toJson(self): + return str(self._asm).replace('\'', "\"") + + def getSubPartsLink(self, group): + groupLink = {} + for el in group: + if (is_object_solid(el)): + if str(el.Shape).find('Solid') != -1: + if groupLink.get(el.Label) == None: + groupLink[el.Label] = [] + for i in el.Group: + if str(i).find('Pad') != -1: + groupLink[el.Label].append(i) + if groupLink.__len__() == 0: + return None + return groupLink + + def getLinkedProperty(self): + return self._asm diff --git a/cad_generation/usecases/export_assembly_them_all_usecase.py b/cad_generation/usecases/export_assembly_them_all_usecase.py new file mode 100644 index 0000000..b8f0a57 --- /dev/null +++ b/cad_generation/usecases/export_assembly_them_all_usecase.py @@ -0,0 +1,92 @@ + + +from typing import List +import FreeCAD as App +import Part +from model.join_mesh_model import JoinMeshModel +from model.mesh_part_model import MeshPartModel +from helper.fs import FS +from helper.is_solid import is_object_solid +from model.simple_copy_part_model import SimpleCopyPartModel +from model.files_generator import FolderGenerator +from usecases.assembly_parse_usecase import AssemblyParseUseCase +import os +import json + + +class ExportAssemblyThemAllUseCase: + + def call(self, path): + assembly = AssemblyParseUseCase().getAsm() + asmStructure = {} + inc = 0 + for el in assembly: + if (inc != 0): + asmStructure[inc] = { + "child": el, + "parents": assembly[0:inc] + } + inc += 1 + objectsFreeCad = App.ActiveDocument.Objects + asmSolids = {} + for k, v in asmStructure.items(): + assemblyParentList = v['parents'] + assemblyChild = v['child'] + for el in assemblyParentList: + for solid in objectsFreeCad: + if (el == solid.Label): + if (asmSolids.get(k) is None): + + asmSolids[k] = {'parents': [], 'child': list( + filter(lambda x: x.Label == assemblyChild, objectsFreeCad))[0]} + + asmSolids[k]['parents'].append(solid) + + inc = 0 + for k, v in asmSolids.items(): + geometry = {"0": [], "1": []} + if (k != 0): + App.activeDocument().addObject("Part::Compound", "Compound") + + copyLinks = list( + map(lambda el: SimpleCopyPartModel(el), v['parents'])) + + if copyLinks != None: + App.activeDocument().Compound.Links = list( + map(lambda el: el.getPart(), copyLinks)) + + object = App.activeDocument().getObject('Compound') + boundBox = object.Shape.BoundBox + geometry['0'].append(boundBox.XMax) + geometry['0'].append(boundBox.YMax) + geometry['0'].append(boundBox.ZMax) + + os.makedirs( + path + FolderGenerator.ASSEMBlY.value + '/' + '0000' + str(k)) + boundBoxChild = v['child'].Shape.BoundBox + geometry['1'].append(boundBoxChild.XMax) + geometry['1'].append(boundBoxChild.YMax) + geometry['1'].append(boundBoxChild.ZMax) + meshParents = [] + + for el in v['parents']: + meshParents.append(MeshPartModel(el)) + joinMesh = JoinMeshModel(meshParents) + for el in meshParents: + el.remove() + import importOBJ + importOBJ.export(joinMesh.mesh, path + FolderGenerator.ASSEMBlY.value + + '/' + '0000' + str(k) + '/' + str(1) + '.obj') + joinMesh.remove() + importOBJ.export(v['child'], path + FolderGenerator.ASSEMBlY.value + + '/' + '0000' + str(k) + '/' + str(0) + '.obj') + FS.writeFile(json.dumps(geometry), path + FolderGenerator.ASSEMBlY.value + + '/' + '0000' + str(k) + '/', 'translation.json') + + App.ActiveDocument.removeObject("Compound") + for el in copyLinks: + el.remove() + App.activeDocument().recompute() + inc += 1 + + diff --git a/cad_generation/usecases/export_usecase.py b/cad_generation/usecases/export_usecase.py new file mode 100644 index 0000000..fed67fa --- /dev/null +++ b/cad_generation/usecases/export_usecase.py @@ -0,0 +1,36 @@ +# import importDAE +import Mesh +import FreeCAD as App +from model.files_generator import FolderGenerator +from helper.is_solid import is_object_solid +from enum import Enum + +class EXPORT_TYPES(Enum): + STL = 'STL' + DAO = 'DAO' + OBJ = 'OBJ' + + +class ExportUseCase: + def call(path: str, type: EXPORT_TYPES): + meshes = {} + for el in App.ActiveDocument.Objects: + if (is_object_solid(el)): + match type.value: + case EXPORT_TYPES.STL.value: + Mesh.export([el], path + '/' + FolderGenerator.SDF.value + + '/' + FolderGenerator.MESHES.value + '/' + el.Label + '.stl') + meshes[el.Label] = '/' + FolderGenerator.MESHES.value + \ + '/' + el.Label + '.stl' + + # case EXPORT_TYPES.DAO.value: + # importDAE.export([el], path + '/' + FolderGenerator.SDF.value + + # '/' + FolderGenerator.MESHES.value + '/' + el.Label + '.dae') + case EXPORT_TYPES.OBJ.value: + import importOBJ + importOBJ.export([el], path + '/' + FolderGenerator.SDF.value + + '/' + FolderGenerator.MESHES.value + '/' + el.Label + '.obj') + meshes[el.Label] = '/' + FolderGenerator.MESHES.value + \ + '/' + el.Label + '.obj' + print(300) + return meshes diff --git a/cad_generation/usecases/geometry_usecase.py b/cad_generation/usecases/geometry_usecase.py new file mode 100644 index 0000000..13ebfd2 --- /dev/null +++ b/cad_generation/usecases/geometry_usecase.py @@ -0,0 +1,58 @@ + +import FreeCAD as App +from helper.is_solid import is_object_solid + + +class GeometryUseCase: + def call() -> dict: + labels = [] + Error = False + for el in App.ActiveDocument.Objects: + try: + + if is_object_solid(el): + labels.append(el.Label) + + geometry = { + "euler": { + "x": None, + "y": None, + "z": None + }, + "position": { + "x": None, + "y": None, + "z": None + }, + "rotation": { + "x": None, + "y": None, + "z": None + }, + "center": { + "x": None, + "y": None, + "z": None + }, + + } + + boundBox = el.Shape.BoundBox + geometry["center"]["x"] = boundBox.Center.x + geometry["center"]["y"] = boundBox.Center.y + geometry["center"]["z"] = boundBox.Center.z + geometry["position"]['x'] = boundBox.XMax + geometry["position"]['y'] = boundBox.YMax + geometry["position"]['z'] = boundBox.ZMax + rotation = el.Placement.Rotation + geometry["rotation"]['x'] = rotation.Axis.z + geometry["rotation"]['y'] = rotation.Axis.y + geometry["rotation"]['z'] = rotation.Axis.z + euler = el.Placement.Rotation.toEuler() + geometry["euler"]['x'] = euler[0] + geometry["euler"]['y'] = euler[1] + geometry["euler"]['z'] = euler[2] + except Exception as e: + print(e) + # App.Console.PrintMessage("Clicked on position: ("+str(pos[0])+", "+str(pos[1])+")\n") + return {"geometry": geometry, "labels": labels, "label": el.Label} diff --git a/cad_generation/usecases/get_sdf_geometry_usecase.py b/cad_generation/usecases/get_sdf_geometry_usecase.py new file mode 100644 index 0000000..45869c5 --- /dev/null +++ b/cad_generation/usecases/get_sdf_geometry_usecase.py @@ -0,0 +1,68 @@ +import FreeCAD as App +from model.sdf_geometry_model import SdfGeometryModel + +from helper.is_solid import is_object_solid + + +class SdfGeometryUseCase: + ShapePropertyCheck = ['Mass','MatrixOfInertia','Placement', ] + PartPropertyCheck = ['Shape'] + def call(self, stlPaths:dict) -> list[SdfGeometryModel]: + materialSolid = {} + for el in App.ActiveDocument.Objects: + if str(el) == '': + friction = el.Material.get('SlidingFriction') + for i in el.References: + materialSolid[i[0].Label] = friction + geometry = [] + try: + for el in App.ActiveDocument.Objects: + if is_object_solid(el): + mass = el.Shape.Mass + inertia = el.Shape.MatrixOfInertia + pos = el.Shape.Placement + inertia = el.Shape.MatrixOfInertia + name = el.Label + ixx = str(inertia.A11 / 1000000) + ixy = str(inertia.A12 / 1000000) + ixz = str(inertia.A13 / 1000000) + iyy = str(inertia.A22 / 1000000) + iyz = str(inertia.A23 / 1000000) + izz = str(inertia.A33 / 1000000) + massSDF = str(mass / 1000000) + posX = str(pos.Base[0] / 1000000) + posY = str(pos.Base[1] / 1000000) + posZ = str(pos.Base[2] / 1000000) + eulerX = str(pos.Rotation.toEuler()[0]) + eulerY = str(pos.Rotation.toEuler()[1]) + eulerZ = str(pos.Rotation.toEuler()[2]) + + geometry.append( + SdfGeometryModel( + stl=stlPaths.get(el.Label), + name=name, + ixx=ixx, + ixz=ixz, + ixy=ixy, + iyy=iyy, + iyz=iyz, + izz=izz, + massSDF=massSDF, + posX=posX, + posY=posY, + posZ=posZ, + eulerX=eulerX, + eulerY=eulerY, + eulerZ=eulerZ, + friction=materialSolid.get(el.Label) or '', + ) + ) + except Exception as e: + print(200) + + return geometry + + + + + diff --git a/cad_stability_check/.gitignore b/cad_stability_check/.gitignore new file mode 100644 index 0000000..2b2f40c --- /dev/null +++ b/cad_stability_check/.gitignore @@ -0,0 +1,95 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# dotenv +.env + +# virtualenv +.venv +venv/ +ENV/ + +# Spyder project settings +.spyderproject + +# Rope project settings +.ropeproject +env.json \ No newline at end of file diff --git a/cad_stability_check/main.py b/cad_stability_check/main.py new file mode 100644 index 0000000..b4684e8 --- /dev/null +++ b/cad_stability_check/main.py @@ -0,0 +1,79 @@ +import FreeCAD as App +import json +import re +from pyquaternion import Quaternion + +def importObjAtPath(path: str): + import importOBJ + importOBJ.insert(u"" + path, App.ActiveDocument.Label) + + pass + + +def getFullPathObj(assemblyFolder: str, name: str): + return assemblyFolder + 'sdf/meshes/' + name + '.obj' + + +def computedStabiliti(refElement, childElement): + b = childElement.Shape.BoundBox + App.activeDocument().addObject("Part::MultiCommon", "Common") + App.activeDocument().Common.Shapes = [refElement, childElement, ] + App.ActiveDocument.getObject('Common').ViewObject.ShapeColor = getattr(App.getDocument('cubes').getObject( + refElement.Name).getLinkedObject(True).ViewObject, 'ShapeColor', App.getDocument('cubes').getObject('Common').ViewObject.ShapeColor) + App.ActiveDocument.getObject('Common').ViewObject.DisplayMode = getattr(App.getDocument('cubes').getObject( + childElement.Name).getLinkedObject(True).ViewObject, 'DisplayMode', App.getDocument('cubes').getObject('Common').ViewObject.DisplayMode) + App.ActiveDocument.recompute() + obj = App.ActiveDocument.getObjectsByLabel('Common')[0] + + shp = obj.Shape + bbox = shp.BoundBox + if bbox.XLength == b.XLength and bbox.YLength == b.YLength and b.ZLength == bbox.ZLength: + return True + return False + + +def main(): + App.newDocument() + env = json.loads((open('./env.json')).read()) + coordinatsFilePath = env.get('pathToTheSimulationCoordinatesFile') + assemblyFolder = env.get('generationFolder') + buildNumber = int(re.findall(r'\d', coordinatsFilePath)[0]) + + assemblyStructure = json.loads( + (open(assemblyFolder + 'step-structure.json')).read()) + assemblyNumber = int(buildNumber) + activeDetail = assemblyStructure[assemblyNumber] + + subassemblyNotParticipatingInMarkup = assemblyStructure[0:assemblyNumber - 1] + detailOfTheMarkingZoneOfWhich = assemblyStructure[assemblyNumber - 1] + importObjAtPath(getFullPathObj(assemblyFolder, activeDetail)) + importObjAtPath(getFullPathObj( + assemblyFolder, detailOfTheMarkingZoneOfWhich)) + meshMark = App.ActiveDocument.Objects[0] + meshDetailOfTheMarkZone = App.ActiveDocument.Objects[1] + meshMark.ViewObject.ShapeColor = (0.31, 0.77, 0.87) + meshDetailOfTheMarkZone.ViewObject.ShapeColor = (0.68, 0.66, 0.95) + for el in list(map(lambda el: getFullPathObj(assemblyFolder, el), subassemblyNotParticipatingInMarkup)): + importObjAtPath(el) + for el in App.ActiveDocument.Objects[2:App.ActiveDocument.Objects.__len__()]: + el.ViewObject.ShapeColor = (0.32, 0.05, 0.38) + + coordinats = json.loads((open(coordinatsFilePath)).read()) + inc = 1 + for el in App.ActiveDocument.Objects: + pos = coordinats[inc]['position'] + qua = coordinats[inc]['quaternion'] + new_quaternion = Quaternion(qua[0], qua[1], qua[2], qua[3]) + rotation_matrix = new_quaternion.rotation_matrix + current_position = el.Placement.Base + new_position = App.Vector(current_position.x, current_position.y, current_position.z) + new_placement = App.Placement(new_position, rotation_matrix) + el.Placement = new_placement + App.ActiveDocument.recompute() + el.Placement.move(App.Vector(pos[0], pos[1], pos[2])) + + print(computedStabiliti(meshMark, meshDetailOfTheMarkZone)) + pass + + +main() diff --git a/cad_stability_input/.gitignore b/cad_stability_input/.gitignore new file mode 100644 index 0000000..2b2f40c --- /dev/null +++ b/cad_stability_input/.gitignore @@ -0,0 +1,95 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# dotenv +.env + +# virtualenv +.venv +venv/ +ENV/ + +# Spyder project settings +.spyderproject + +# Rope project settings +.ropeproject +env.json \ No newline at end of file diff --git a/cad_stability_input/LICENSE b/cad_stability_input/LICENSE new file mode 100644 index 0000000..5f2dd7f --- /dev/null +++ b/cad_stability_input/LICENSE @@ -0,0 +1,505 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +(This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.) + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random + Hacker. + + {signature of Ty Coon}, 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + diff --git a/cad_stability_input/README.md b/cad_stability_input/README.md new file mode 100644 index 0000000..e69de29 diff --git a/cad_stability_input/gui/__init__.py b/cad_stability_input/gui/__init__.py new file mode 100644 index 0000000..f80dcdc --- /dev/null +++ b/cad_stability_input/gui/__init__.py @@ -0,0 +1,4 @@ +import os +from .version import __version__ + +ICONPATH = os.path.join(os.path.dirname(__file__), "resources") diff --git a/cad_stability_input/gui/init_gui.py b/cad_stability_input/gui/init_gui.py new file mode 100644 index 0000000..65c0bdb --- /dev/null +++ b/cad_stability_input/gui/init_gui.py @@ -0,0 +1,89 @@ +import os +import FreeCADGui as Gui +import FreeCAD as App +from PySide.QtCore import QT_TRANSLATE_NOOP +import shutil +ICONPATH = os.path.join(os.path.dirname(__file__), "resources") +zone = "StabilityZone" +import requests +import importOBJ + + +class AddStabilityZone: + def __init__(self): + pass + + def GetResources(self): + return {'Pixmap': os.path.join(ICONPATH, "stability_zone.svg"), + 'Accel': "Ctrl+A", + 'MenuText': QT_TRANSLATE_NOOP("My_Command", "My Command"), + 'ToolTip': QT_TRANSLATE_NOOP("My_Command", "Runs my command in the active document")} + + def Activated(self): + App.ActiveDocument.addObject("Part::Box", "Box") + App.ActiveDocument.ActiveObject.Label = zone + selected_object = App.ActiveDocument.getObjectsByLabel(zone)[0] + selected_object.ViewObject.Transparency = 50 + selected_object.ViewObject.ShapeColor = (0.15, 0.80, 0.50) + pass + + def IsActive(self): + return True + + +class SyncServer: + + httpURL = None + def __init__(self, httpURL): + self.httpURL = httpURL + + + def GetResources(self): + return {'Pixmap': os.path.join(ICONPATH, "server_sync.svg"), + 'Accel': "Ctrl+A", + 'MenuText': QT_TRANSLATE_NOOP("My_Command", "My Command"), + 'ToolTip': QT_TRANSLATE_NOOP("My_Command", "Runs my command in the active document")} + + def Activated(self): + StabilityZone = App.ActiveDocument.getObjectsByLabel(zone) + dir_path = os.path.dirname(os.path.realpath(__file__)) + dir_out = dir_path + '/out/' + if not os.path.exists(dir_out): + os.makedirs(dir_out) + importOBJ.export(StabilityZone, u"" + dir_out + 'StabilityZone.obj') + shutil.make_archive(dir_out + '/' + 'geometry', 'zip',) + zipArch = dir_out + 'geometry.zip' + requests.post(url=self.httpURL, files={'zip': open(zipArch, "rb")}) + shutil.rmtree(dir_out) + pass + + def IsActive(self): + return True + + +class StabilityWorkbench(Gui.Workbench): + + MenuText = "stability workbench" + ToolTip = "a simple template workbench" + Icon = os.path.join(ICONPATH, "template_resource.svg") + toolbox = ['AddStabilityZone', 'SyncServer'] + httpURL = None + def __init__(self,httpURL): + self.httpURL = httpURL + + + def GetClassName(self): + return "Gui::PythonWorkbench" + + def Initialize(self): + Gui.addCommand('AddStabilityZone', AddStabilityZone()) + Gui.addCommand('SyncServer', SyncServer( + self.httpURL)) + self.appendToolbar("Tools", self.toolbox) + self.appendMenu("Tools", self.toolbox) + + def Activated(self): + pass + + def Deactivated(self): + pass diff --git a/cad_stability_input/gui/my_numpy_function.py b/cad_stability_input/gui/my_numpy_function.py new file mode 100644 index 0000000..d74c650 --- /dev/null +++ b/cad_stability_input/gui/my_numpy_function.py @@ -0,0 +1,4 @@ +import numpy as np + +def my_foo(value): + return np.sqrt(value) diff --git a/cad_stability_input/gui/resources/server_sync.svg b/cad_stability_input/gui/resources/server_sync.svg new file mode 100644 index 0000000..da595a2 --- /dev/null +++ b/cad_stability_input/gui/resources/server_sync.svg @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/cad_stability_input/gui/resources/stability_zone.svg b/cad_stability_input/gui/resources/stability_zone.svg new file mode 100644 index 0000000..3f7686a --- /dev/null +++ b/cad_stability_input/gui/resources/stability_zone.svg @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/cad_stability_input/gui/resources/template_resource.svg b/cad_stability_input/gui/resources/template_resource.svg new file mode 100644 index 0000000..509be26 --- /dev/null +++ b/cad_stability_input/gui/resources/template_resource.svg @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + T + diff --git a/cad_stability_input/gui/version.py b/cad_stability_input/gui/version.py new file mode 100644 index 0000000..3486632 --- /dev/null +++ b/cad_stability_input/gui/version.py @@ -0,0 +1 @@ +__version__ = "0.8.1" \ No newline at end of file diff --git a/cad_stability_input/main.py b/cad_stability_input/main.py new file mode 100644 index 0000000..3b646fd --- /dev/null +++ b/cad_stability_input/main.py @@ -0,0 +1,48 @@ +import os +import FreeCADGui as Gui +import FreeCAD as App +from gui.init_gui import StabilityWorkbench +import json + + +def importObjAtPath(path: str): + import importOBJ + importOBJ.insert(u"" + path, App.ActiveDocument.Label) + + pass + + +def getFullPathObj(assemblyFolder: str, name: str): + return assemblyFolder + 'sdf/meshes/' + name + '.obj' + + +def main(): + App.newDocument() + env = json.loads((open('./env.json')).read()) + assemblyFolder = env.get('assemblyFolder') + + assemblyStructure = json.loads( + (open(assemblyFolder + 'step-structure.json')).read()) + assemblyNumber = int(env.get('buildNumber')) - 1 + activeDetail = assemblyStructure[assemblyNumber] + + subassemblyNotParticipatingInMarkup = assemblyStructure[0:assemblyNumber - 1] + detailOfTheMarkingZoneOfWhich = assemblyStructure[assemblyNumber - 1] + importObjAtPath(getFullPathObj(assemblyFolder, activeDetail)) + importObjAtPath(getFullPathObj( + assemblyFolder, detailOfTheMarkingZoneOfWhich)) + meshMark = App.ActiveDocument.Objects[0] + meshDetailOfTheMarkZone = App.ActiveDocument.Objects[1] + meshMark.ViewObject.ShapeColor = (0.31, 0.77, 0.87) + meshDetailOfTheMarkZone.ViewObject.ShapeColor = (0.68, 0.66, 0.95) + for el in list(map(lambda el: getFullPathObj(assemblyFolder, el), subassemblyNotParticipatingInMarkup)): + importObjAtPath(el) + for el in App.ActiveDocument.Objects[2:App.ActiveDocument.Objects.__len__()]: + el.ViewObject.ShapeColor = (0.32, 0.05, 0.38) + Gui.SendMsgToActiveView("ViewSelection") + + Gui.addWorkbench(StabilityWorkbench(env.get('resultURL'))) + Gui.activateWorkbench("StabilityWorkbench") + + +main() diff --git a/cg/blender/import_fcstd/import_cad_objects.py b/cg/blender/import_fcstd/import_cad_objects.py index c997f8c..49845ff 100644 --- a/cg/blender/import_fcstd/import_cad_objects.py +++ b/cg/blender/import_fcstd/import_cad_objects.py @@ -61,14 +61,16 @@ render = '_render' def obj_importer(filename, - linear_deflection, - angular_deflection, + tesselation_method='Standard', + linear_deflection=0.1, + angular_deflection=30.0, + fem_size=5.0, update=False, scene_placement=True, skiphidden=True, scale=0.001, select=True, - nonsolid_property = 'Robossembler_NonSolid'): + nonsolid_property='Robossembler_NonSolid'): ''' Reads a FreeCAD .FCStd file and creates Blender objects ''' @@ -124,11 +126,20 @@ def obj_importer(filename, shape = obj.Shape.copy() shape.Placement = obj.Placement.inverse().multiply(shape.Placement) meshfromshape = doc.addObject('Mesh::Feature','Mesh') - meshfromshape.Mesh = MeshPart.meshFromShape( - Shape=shape, - LinearDeflection=linear_deflection, - AngularDeflection=math.radians(angular_deflection), - Relative=False) + if tesselation_method == 'Standard': + meshfromshape.Mesh = MeshPart.meshFromShape( + Shape=shape, + LinearDeflection=linear_deflection, + AngularDeflection=math.radians(angular_deflection), + Relative=False) + elif tesselation_method == 'FEM': + meshfromshape.Mesh = MeshPart.meshFromShape( + Shape=shape, + MaxLength=fem_size) + else: + raise TypeError('Wrong tesselation method! ' + 'Standard and FEM methods are supported only!') + break t = meshfromshape.Mesh.Topology verts = [[v.x,v.y,v.z] for v in t[0]] faces = t[1] @@ -185,17 +196,18 @@ def obj_importer(filename, # losted root lcs inlet workaround lcs_objects = lcs_collection.objects - root_lcs = [lcs for lcs in lcs_objects if lcs.name.endswith(root)][0] - root_inlet_name = ('{}{}'.format(root_lcs.name.split(root)[0], inlet)) - if not bpy.data.objects.get(root_inlet_name): - root_inlet = bpy.data.objects.new(root_inlet_name, None) - root_inlet.empty_display_type = 'ARROWS' - root_inlet.empty_display_size = 0.1 - root_inlet.show_in_front = True - root_inlet.location = root_lcs.location - root_inlet.rotation_euler = root_lcs.rotation_euler - root_inlet.parent = root_lcs.parent - lcs_collection.objects.link(root_inlet) + if lcs_objects: + root_lcs = [lcs for lcs in lcs_objects if lcs.name.endswith(root)][0] + root_inlet_name = ('{}{}'.format(root_lcs.name.split(root)[0], inlet)) + if not bpy.data.objects.get(root_inlet_name): + root_inlet = bpy.data.objects.new(root_inlet_name, None) + root_inlet.empty_display_type = 'ARROWS' + root_inlet.empty_display_size = 0.1 + root_inlet.show_in_front = True + root_inlet.location = root_lcs.location + root_inlet.rotation_euler = root_lcs.rotation_euler + root_inlet.parent = root_lcs.parent + lcs_collection.objects.link(root_inlet) FreeCAD.closeDocument(docname) diff --git a/cg/freecad/Frames/scenarios/robossembler_freecad_export_scenario.py b/cg/freecad/Frames/scenarios/robossembler_freecad_export_scenario.py index 71def3b..eb40dfe 100644 --- a/cg/freecad/Frames/scenarios/robossembler_freecad_export_scenario.py +++ b/cg/freecad/Frames/scenarios/robossembler_freecad_export_scenario.py @@ -18,7 +18,7 @@ import shutil class RobossemblerFreeCadExportScenario: def call(self): - + path = self.qtGuiFeature() if path == None: return diff --git a/cg/pipeline/freecad_to_asset.py b/cg/pipeline/freecad_to_asset.py index d55e484..96829be 100644 --- a/cg/pipeline/freecad_to_asset.py +++ b/cg/pipeline/freecad_to_asset.py @@ -59,9 +59,12 @@ hightpoly = '_hp' lowpoly = '_lp' render = '_render' + def freecad_asset_pipeline(fcstd_path, + tesselation_method, linear_deflection, angular_deflection, + fem_size, mesh_export_path=None, json_path=None, blend_path=None, @@ -74,8 +77,10 @@ def freecad_asset_pipeline(fcstd_path, # import objects objs_for_render = obj_importer(fcstd_path, - linear_deflection, - angular_deflection) + tesselation_method, + linear_deflection, + angular_deflection, + fem_size) # restructuring hierarchy by lcs points lcs_objects = restruct_hierarchy() @@ -130,10 +135,14 @@ if __name__ == '__main__': description='Convert and setup FreeCAD solid objects to 3d assets mesh files.') parser.add_argument( '--fcstd_path', type=str, help='Path to source FreeCAD scene', required=True) + parser.add_argument( + '--tesselation_method', type=str, help='Select tesselation method: Standard or FEM.', default='Standard', required=False) parser.add_argument( '--linear_deflection', type=float, help='Max linear distance error', default=0.1, required=False) parser.add_argument( '--angular_deflection', type=float, help='Max angular distance error', default=20.0, required=False) + parser.add_argument( + '--fem_size', type=float, help='For FEM method only! Finite element size in mm', default=1.0, required=False) parser.add_argument( '--mesh_export_path', type=str, help='Path for export meshes', required=False) parser.add_argument( @@ -145,8 +154,10 @@ if __name__ == '__main__': args = parser.parse_args() freecad_asset_pipeline(args.fcstd_path, + args.tesselation_method, args.linear_deflection, args.angular_deflection, + args.fem_size, args.mesh_export_path, args.json_path, args.blend_path, diff --git a/geometric_feasibility_predicate/README.MD b/geometric_feasibility_predicate/README.MD new file mode 100644 index 0000000..7185164 --- /dev/null +++ b/geometric_feasibility_predicate/README.MD @@ -0,0 +1 @@ +freecadcmd main.py \ No newline at end of file diff --git a/geometric_feasibility_predicate/env.json b/geometric_feasibility_predicate/env.json new file mode 100644 index 0000000..2375211 --- /dev/null +++ b/geometric_feasibility_predicate/env.json @@ -0,0 +1,4 @@ +{ + "cadFilePath":"", + "outPath":"" +} \ No newline at end of file diff --git a/geometric_feasibility_predicate/main.py b/geometric_feasibility_predicate/main.py new file mode 100644 index 0000000..8623d7c --- /dev/null +++ b/geometric_feasibility_predicate/main.py @@ -0,0 +1,358 @@ +import FreeCAD as App +import uuid +import os +import json +from typing import List, Dict, Any, TypeVar, Callable, Type, cast + + +class FreeCadRepository: + _solids = [] + + def getAllSolids(self): + if (self._solids.__len__() == 0): + for part in App.ActiveDocument.Objects: + if (self.is_object_solid(part)): + self._solids.append(part) + + return self._solids + + def is_object_solid(self, obj): + if not isinstance(obj, App.DocumentObject): + return False + if hasattr(obj, 'Group'): + return False + + if not hasattr(obj, 'Shape'): + return False + if not hasattr(obj.Shape, 'Mass'): + return False + if not hasattr(obj.Shape, 'Solids'): + return False + + if len(obj.Shape.Solids) == 0: + return False + + return True + + +T = TypeVar("T") + + +def from_list(f: Callable[[Any], T], x: Any) -> List[T]: + assert isinstance(x, list) + return [f(y) for y in x] + + +def from_str(x: Any) -> str: + assert isinstance(x, str) + return x + + +def from_dict(f: Callable[[Any], T], x: Any) -> Dict[str, T]: + assert isinstance(x, dict) + return {k: f(v) for (k, v) in x.items()} + + +def to_class(c: Type[T], x: Any) -> dict: + assert isinstance(x, c) + return cast(Any, x).to_dict() + + +class AdjacencyMatrix: + matrixError: Dict[str,str] = {} + all_parts: List[str] + first_detail: str + matrix: Dict[str, List[str]] + + def __init__(self, all_parts: List[str], first_detail: str, matrix: Dict[str, List[str]]) -> None: + self.all_parts = all_parts + self.first_detail = first_detail + self.matrix = matrix + self.validateMatrix() + + def whatPlaceLeadingPartIndex(self): + i = 0 + for el in self.matrix: + if el == self.first_detail: + return i + i = +1 + def validateMatrix(self): + for el in self.all_parts: + if(self.matrix.get(el) == None): + self.matrixError[el] = 'Not found adjacency ' + el + @staticmethod + def from_dict(obj: Any) -> 'AdjacencyMatrix': + assert isinstance(obj, dict) + all_pars = from_list(from_str, obj.get("allPars")) + first_detail = from_str(obj.get("firstDetail")) + matrix = from_dict(lambda x: from_list(from_str, x), obj.get("matrix")) + + return AdjacencyMatrix(all_pars, first_detail, matrix) + + def to_dict(self) -> dict: + result: dict = {} + result["allPars"] = from_list(from_str, self.all_parts) + result["firstDetail"] = from_str(self.first_detail) + result["matrix"] = from_dict( + lambda x: from_list(from_str, x), self.matrix) + if(self.matrixError.values().__len__() == 0): + result['matrixError'] = None + else: + result['matrixError'] = self.matrixError + return result + + def getDictMatrix(self) -> dict: + result = {} + + for k, v in self.matrix.items(): + result[k] = {} + for el in v: + result[k][el] = el + + return result + + +def adjacency_matrix_from_dict(s: Any) -> AdjacencyMatrix: + return AdjacencyMatrix.from_dict(s) + + +def adjacency_matrix_to_dict(x: AdjacencyMatrix) -> Any: + return to_class(AdjacencyMatrix, x) + + +class FreeCadMetaModel(object): + + def __init__(self, label, vertex) -> None: + self.label = label + self.vertex = vertex + + +collision_squares_labels = [] + + +class MeshGeometryCoordinateModel(object): + + def __init__(self, x, y, z, label,): + self.x = x + self.y = y + self.z = z + self.label = label + self.cadLabel = '' + + def initializePrimitivesByCoordinate(self, detailSquares): + uuidDoc = str(uuid.uuid1()) + App.ActiveDocument.addObject("Part::Box", "Box") + App.ActiveDocument.ActiveObject.Label = uuidDoc + App.ActiveDocument.recompute() + part = App.ActiveDocument.getObjectsByLabel(uuidDoc)[0] + collision_squares_labels.append(uuidDoc) + part.Width = 2 + part.Height = 2 + part.Length = 2 + part.Placement = App.Placement( + App.Vector(self.x - 1, self.y - 1, self.z - 1), + App.Rotation(App.Vector(0.00, 0.00, 1.00), 0.00)) + if (detailSquares.get(self.label) is None): + detailSquares[self.label] = [] + detailSquares[self.label].append(self) + self.cadLabel = uuidDoc + App.ActiveDocument.recompute() + + +class FS: + def readJSON(path: str): + return json.loads((open(path)).read()) + + def writeFile(data, filePath, fileName): + + file_to_open = filePath + fileName + + f = open(file_to_open, 'w', encoding='utf8') + + f.write(data) + + def readFile(path: str): + return open(path).read() + + def readFilesTypeFolder(pathFolder: str, fileType='.json'): + filesJson = list( + filter(lambda x: x[-fileType.__len__():] == fileType, os.listdir(pathFolder))) + return filesJson + + +class GetAllPartsLabelsUseCase: + def call(self): + parts = [] + for part in FreeCadRepository().getAllSolids(): + parts.append(part.Label) + return parts + + +def isUnique(array, element): + for i in array: + if i == element: + return False + + return True + + +class GetCollisionAtPrimitiveUseCase(object): + + def call(self, freeCadMetaModels, detailSquares) -> Dict[str, List[str]]: + matrix: Dict[str, List[str]] = {} + for model in freeCadMetaModels: + activePart = App.ActiveDocument.getObjectsByLabel(model.label)[0] + for key in detailSquares: + if (model.label != key): + for renderPrimitive in detailSquares[key]: + primitivePart = App.ActiveDocument.getObjectsByLabel( + renderPrimitive.cadLabel)[0] + collisionResult: int = int( + activePart.Shape.distToShape(primitivePart.Shape)[0]) + if (collisionResult == 0): + if matrix.get(model.label) == None: + matrix[model.label] = [renderPrimitive.label] + else: + if isUnique(matrix[model.label], renderPrimitive.label): + matrix[model.label].append( + renderPrimitive.label + ) + return matrix + + +class GetFirstDetailUseCase: + def call(self): + return FreeCadRepository().getAllSolids()[0].Label + + +class GetPartPrimitiveCoordinatesUseCase(object): + + def call(self, freeCadMetaModels): + meshCoordinates: list[MeshGeometryCoordinateModel] = [] + for model in freeCadMetaModels: + vertexesDetail = model.vertex + labelDetail = model.label + for coords in vertexesDetail: + detailVertex = MeshGeometryCoordinateModel( + coords.X, + coords.Y, + coords.Z, + labelDetail, + ) + meshCoordinates.append(detailVertex) + + return meshCoordinates + + +class InitPartsParseUseCase(): + + def call(self): + product_details = [] + for part in FreeCadRepository().getAllSolids(): + if part is not None: + model = FreeCadMetaModel(part.Label, part.Shape.Vertexes) + if (model is not None): + product_details.append(model) + return product_details + + +class RenderPrimitiveUseCase(object): + + def call(self, meshModels: list[MeshGeometryCoordinateModel], detailSquares) -> None: + for mesh in meshModels: + mesh.initializePrimitivesByCoordinate(detailSquares) + + +class ClearWorkSpaceDocumentUseCase(object): + def call(self, detailSquares): + for key in detailSquares: + for renderPrimitive in detailSquares[key]: + primitivePart = App.ActiveDocument.getObjectsByLabel( + renderPrimitive.cadLabel)[0] + App.ActiveDocument.removeObject(primitivePart.Name) + + +class RenderPrimitivesScenario(object): + + def __init__( + self, + initPartsParseUseCase: InitPartsParseUseCase, + getPartPrimitiveCoordinatesUseCase: GetPartPrimitiveCoordinatesUseCase, + renderPrimitiveUseCase: RenderPrimitiveUseCase, + getCollisionAtPrimitives: GetCollisionAtPrimitiveUseCase, + clearWorkSpaceDocument: ClearWorkSpaceDocumentUseCase, + ) -> None: + self.initPartsParseUseCase = initPartsParseUseCase + self.getPartPrimitiveCoordinatesUseCase = getPartPrimitiveCoordinatesUseCase + self.renderPrimitiveUseCase = renderPrimitiveUseCase + self.getCollisionAtPrimitives = getCollisionAtPrimitives + self.clearWorkSpaceDocument = clearWorkSpaceDocument + + def call(self) -> None: + meshCoordinates = [] + detailSquares = {} + parts = self.initPartsParseUseCase.call() + meshCoordinates = self.getPartPrimitiveCoordinatesUseCase.call(parts) + self.renderPrimitiveUseCase.call(meshCoordinates, detailSquares) + matrix = self.getCollisionAtPrimitives.call(parts, detailSquares) + self.clearWorkSpaceDocument.call(detailSquares) + return matrix + + +class ClearWorkSpaceDocumentUseCase(object): + def call(self, detailSquares): + for key in detailSquares: + for renderPrimitive in detailSquares[key]: + primitivePart = App.ActiveDocument.getObjectsByLabel( + renderPrimitive.cadLabel)[0] + App.ActiveDocument.removeObject(primitivePart.Name) + + +class CadAdjacencyMatrix: + def primitiveMatrix(self): + matrix = RenderPrimitivesScenario( + InitPartsParseUseCase(), + GetPartPrimitiveCoordinatesUseCase(), + RenderPrimitiveUseCase(), + GetCollisionAtPrimitiveUseCase(), + ClearWorkSpaceDocumentUseCase(), + ).call() + + return AdjacencyMatrix( + all_parts=GetAllPartsLabelsUseCase().call(), + first_detail=GetFirstDetailUseCase().call(), + matrix=matrix, + ) + + def matrixBySurfaces(self,): + adjaxed = {} + for part in FreeCadRepository().getAllSolids(): + adjaxed[part.Label] = [] + for nextPart in FreeCadRepository().getAllSolids(): + if part.Label != nextPart.Label: + collisionResult: int = int( + part.Shape.distToShape(nextPart.Shape)[0]) + if (collisionResult == 0): + adjaxed[part.Label].append(nextPart.Label) + + return AdjacencyMatrix(all_parts=GetAllPartsLabelsUseCase( + ).call(), first_detail=GetFirstDetailUseCase().call(), + matrix=adjaxed + ) + + +def main(): + env = FS.readJSON('env.json') + cadFile = env['cadFilePath'] + outPath = env['outPath'] + if (cadFile == None): + return TypeError('CadFile not found env.json') + App.open(u'' + cadFile) + + + matrixOut = CadAdjacencyMatrix().primitiveMatrix().to_dict() + import json + FS.writeFile(json.dumps(matrixOut, ensure_ascii=False, indent=4), outPath,'out.json') + + +main() diff --git a/pddl/main.py b/pddl/main.py index 8541124..9c05f1c 100644 --- a/pddl/main.py +++ b/pddl/main.py @@ -5,7 +5,7 @@ from src.model.asm4_structure import Asm4Structure from src.usecases.assembly_to_pddl_use_case import AssemblyToPddlUseCase -# python3 main.py --stepStructurePath /Users/idontsudo/robo/Cube3/step-structure.json --outPath /Users/idontsudo/robo/Cube3/pddl/ +# python3 main.py --stepStructurePath /Users/idontsudo/robo/step-structure.json --outPath /Users/idontsudo/robo/pddl/out/ if __name__ == "__main__": parser = argparse.ArgumentParser() diff --git a/pddl/src/usecases/assembly_to_pddl_use_case.py b/pddl/src/usecases/assembly_to_pddl_use_case.py index 7583043..a6ba8ef 100644 --- a/pddl/src/usecases/assembly_to_pddl_use_case.py +++ b/pddl/src/usecases/assembly_to_pddl_use_case.py @@ -7,13 +7,11 @@ import os class AssemblyToPddlUseCase: def call(assembly: List[str], rootLabel: str): - print(assembly) partType = UserType("part") assemblyType = UserType('assembly') objectsPartPddl = [] objectsAsmToPddl = [] - i = 0 for el in assembly: objectsPartPddl.append(Object(el, partType)) @@ -30,15 +28,26 @@ class AssemblyToPddlUseCase: connected = Fluent('part-of', BoolType(), l_from=partType, l_to=assemblyType) + assemblyOrder = Fluent('assembly_order', BoolType(), + l_from=assemblyType, l_to=assemblyType) i = 0 for el in objectsPartPddl: problem.set_initial_value(connected(el, objectsAsmToPddl[i]), True) i = i+1 goal = Fluent(rootLabel) + problem.add_goal(connected(objectsPartPddl[objectsPartPddl.__len__( ) - 1], objectsAsmToPddl[objectsAsmToPddl.__len__() - 1]),) + + i = 0 + for el in objectsAsmToPddl: + if objectsAsmToPddl[i-1] != objectsAsmToPddl[objectsAsmToPddl.__len__() - 1]: + problem.set_initial_value(assemblyOrder(objectsAsmToPddl[i-1], el), True) + i = i+1 + + problem.add_goal(assemblyOrder(objectsAsmToPddl[objectsAsmToPddl.__len__( + ) - 1], objectsAsmToPddl[objectsAsmToPddl.__len__() - 1]),) return { "problem": unified_planning.io.PDDLWriter(problem).get_problem(), 'domain': FS.readFile(os.path.dirname(os.path.realpath(__file__)) + '/../../mocks' + '/domain.txt'), } - diff --git a/stability_process_predicate/main.py b/stability_process_predicate/main.py new file mode 100644 index 0000000..a4e0304 --- /dev/null +++ b/stability_process_predicate/main.py @@ -0,0 +1,16 @@ +import argparse + +from usecases.stability_check_usecase import StabilityCheckUseCase + +#python3 main.py --aspPath /home/idontsudo/t/framework/asp/out/sdf-generation --buildNumber 3 +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('--aspPath', help='asp folder generation path') + parser.add_argument('--buildNumber', help='FreeCad generation buildNumber') + args = parser.parse_args() + # args.aspPath + # args.buildNumber + StabilityCheckUseCase().call( args.aspPath,args.buildNumber ) + + +main() \ No newline at end of file diff --git a/stability_process_predicate/usecases/stability_check_usecase.py b/stability_process_predicate/usecases/stability_check_usecase.py new file mode 100644 index 0000000..9d37b53 --- /dev/null +++ b/stability_process_predicate/usecases/stability_check_usecase.py @@ -0,0 +1,61 @@ +import numpy as np +import pybullet as p +import time +import pybullet_data +import os +import json + + +class StabilityCheckUseCase: + def call(self, outPath: str, buildNumber: int, duration=500): + DURATION = duration + try: + assemblyUrdf = json.loads( + (open(outPath + 'urdf-generation.json')).read()).get(buildNumber) + except: + return TypeError('not found urfd file or not found build number') + inc = 0 + urdfs = [] + + for el in assemblyUrdf: + inc += 1 + file_to_open = outPath + str(inc) + '.urdf' + + f = open(file_to_open, 'w', encoding='utf-8', + errors='ignore') + f.write(el) + urdfs.append(os.path.abspath(f.name)) + f.close() + + p.connect(p.DIRECT) + + p.setGravity(0, 0, -10) + p.setAdditionalSearchPath(pybullet_data.getDataPath()) + bulletIds = [] + for el in urdfs: + bulletIds.append(p.loadURDF(el)) + p.loadURDF("plane.urdf") + resultCoords = [] + for i in range(DURATION): + if (i + 200 == DURATION): + inc = 0 + for el in bulletIds: + inc += 1 + pos, rot = p.getBasePositionAndOrientation(el) + resultCoords.append({ + 'id': inc, + "quaternion": rot, + "position": pos + }) + p.stepSimulation() + time.sleep(1./240.) + + file_to_open = outPath + buildNumber + "_" + 'stability_coords.json' + + f = open(file_to_open, 'w', encoding='utf-8', + errors='ignore') + f.write(json.dumps(resultCoords)) + for el in urdfs: + os.remove(el) + f.close() + p.disconnect()