cad stability
This commit is contained in:
parent
f59bb9d801
commit
fe714b1123
40 changed files with 1655 additions and 49 deletions
1
asp-review-app/.gitignore
vendored
1
asp-review-app/.gitignore
vendored
|
@ -22,3 +22,4 @@ npm-debug.log*
|
|||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
**/node_modules
|
||||
server/public/
|
1
asp-review-app/server/computed
Submodule
1
asp-review-app/server/computed
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit f59bb9d801660e0728956e007c29aa24767c2c45
|
500
asp-review-app/server/package-lock.json
generated
500
asp-review-app/server/package-lock.json
generated
|
@ -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",
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -61,6 +64,7 @@ export class App {
|
|||
this.app.use("/", route.router);
|
||||
});
|
||||
}
|
||||
|
||||
loadAppDependencies() {
|
||||
locator(new DevEnv());
|
||||
}
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
interface MemoOptions<F extends Fn, S extends unknown[] = unknown[]> {
|
||||
/**
|
||||
* Serialize the function call arguments
|
||||
* This is used to identify cache key
|
||||
*/
|
||||
serialize?: (...args: Parameters<F>) => S;
|
||||
}
|
||||
interface MemoAsyncOptions<F extends Fn> extends MemoOptions<F> {
|
||||
|
@ -22,16 +18,12 @@ type Fn = (...params: any[]) => any;
|
|||
type AsyncFn = (...params: any[]) => Promise<any>;
|
||||
|
||||
interface MemoFunc<F extends Fn> {
|
||||
// Call the target function, if cache is valid, return cache
|
||||
(...args: Parameters<F>): ReturnType<F>;
|
||||
|
||||
// Same with this function
|
||||
get(...args: Parameters<F>): ReturnType<F>;
|
||||
|
||||
// Call the raw function and skip cache
|
||||
raw(...args: Parameters<F>): ReturnType<F>;
|
||||
|
||||
// Clear cache
|
||||
clear(...args: Parameters<F> | []): void | Promise<void>;
|
||||
}
|
||||
|
||||
|
@ -126,7 +118,6 @@ export function memoAsync<F extends AsyncFn>(
|
|||
const root = makeNode<F>();
|
||||
|
||||
const memoFunc = async function (...args: Parameters<F>) {
|
||||
// Serialize args
|
||||
const path = options.serialize ? options.serialize(...args) : args;
|
||||
const cur = walkAndCreate<F, any[]>(root, path);
|
||||
|
||||
|
@ -155,7 +146,6 @@ export function memoAsync<F extends AsyncFn>(
|
|||
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<F extends AsyncFn>(
|
|||
cur.state = State.Error;
|
||||
cur.error = error;
|
||||
|
||||
// Reject other waiting callbacks
|
||||
for (const callback of cur.callbacks ?? []) {
|
||||
callback.rej(error);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,76 @@
|
|||
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<string> {
|
||||
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 = () => {
|
||||
|
||||
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)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,22 +1,34 @@
|
|||
import { promises as fs } from 'fs';
|
||||
import { dirname } from '../../app';
|
||||
import fsSync from "fs";
|
||||
import { reflection } from 'first-di';
|
||||
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) + '/'
|
||||
|
||||
|
@ -25,27 +37,50 @@ export class EntityRepository {
|
|||
}
|
||||
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<String[]> | undefined {
|
||||
return this._fullPath(await fs.readdir(this.path + entity), entity + '/' )
|
||||
|
||||
public async getEntityStorage(entity: string): Promise<String[]> | 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<T>(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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
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";
|
||||
|
||||
|
@ -13,18 +14,19 @@ export class AssemblyController {
|
|||
next: NextFunction
|
||||
) => {
|
||||
const file = req.files;
|
||||
const f = file["freecad"] as IFile;
|
||||
console.log(f)
|
||||
// this.entityRepository.saveRootEntity(f.data, f.name);
|
||||
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 => {};
|
||||
): void => { };
|
||||
|
||||
public createAssembly = (
|
||||
req: Request,
|
||||
|
@ -35,10 +37,65 @@ export class AssemblyController {
|
|||
const file = req.files.freecad as IFile;
|
||||
const buffer = file.data as Buffer;
|
||||
this.entityRepository.saveRootEntity(file.data, file.name);
|
||||
console.log(this.entityRepository);
|
||||
res.sendStatus(200);
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,11 +22,25 @@ export class AssemblyRoute implements Routes {
|
|||
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);
|
||||
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -14,7 +14,6 @@ export class AssemblyPreviewsController {
|
|||
next: NextFunction
|
||||
): Promise<void> => {
|
||||
try {
|
||||
console.log(this.entityRepository)
|
||||
res.send(await this.entityRepository.getAllRootEntity());
|
||||
} catch (error) {
|
||||
next(error);
|
||||
|
@ -30,7 +29,9 @@ export class AssemblyPreviewsController {
|
|||
const entity = await this.entityRepository.getEntityStorage(
|
||||
req.params.id
|
||||
);
|
||||
|
||||
const aspUsage = Number(req.query.count) - 1;
|
||||
|
||||
if (entity === undefined) {
|
||||
res.status(404).json("entity not found");
|
||||
return;
|
||||
|
@ -56,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;
|
||||
|
@ -67,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");
|
||||
});
|
||||
|
@ -145,4 +152,5 @@ export class AssemblyPreviewsController {
|
|||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,25 +2,27 @@ 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',
|
||||
createProject = '/assembly/create',
|
||||
ajaxMatrix = 'matrix.json'
|
||||
}
|
||||
export class HttpRepository {
|
||||
static server = 'http://localhost:3002'
|
||||
static async jsonRequest<T>(method: HttpMethod, url: string, data?: any):Promise<T> {
|
||||
static async jsonRequest<T>(method: HttpMethod, url: string, data?: any): Promise<T> {
|
||||
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<T>(method: HttpMethod, url: string, data?: any):Promise<T> {
|
||||
static async request<T>(method: HttpMethod, url: string, data?: any): Promise<T> {
|
||||
const reqInit = {
|
||||
'body': data,
|
||||
'method': method,
|
||||
|
|
|
@ -10,6 +10,8 @@ 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() {
|
||||
|
@ -30,6 +32,7 @@ function LinkCreateProjectPage() {
|
|||
export const ProjectsPath = "/";
|
||||
export const ProjectScreen: React.FunctionComponent = () => {
|
||||
const [projects, setProjects] = useState<Array<String>>([]);
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
async function fetchData() {
|
||||
|
@ -65,7 +68,15 @@ export const ProjectScreen: React.FunctionComponent = () => {
|
|||
return (
|
||||
<>
|
||||
<Card style={{ width: 300 }}>
|
||||
<div>{el}</div> <Button> Preview insert Path </Button>
|
||||
<div>{el}</div>
|
||||
<Button onClick={() => {
|
||||
navigate(pathAjaxTopologyScreen + el);
|
||||
}} > Preview topology ajax computed </Button>
|
||||
<Button onClick={() => {
|
||||
navigate(pathStabilityScreen + el);
|
||||
}} > Preview stability computed </Button>
|
||||
|
||||
<Button> Preview insert Path </Button>
|
||||
<Button>Preview assembly logical </Button>
|
||||
</Card>
|
||||
</>
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
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<boolean>(false);
|
||||
|
||||
const handleImageChange = function (e: React.ChangeEvent<HTMLInputElement>) {
|
||||
|
@ -21,11 +24,11 @@ const UploadButton = () => {
|
|||
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);
|
||||
formData.append("freecad", file, file.name);
|
||||
setLoading(true);
|
||||
await HttpRepository.request(
|
||||
HttpMethod.POST,
|
||||
|
@ -33,6 +36,7 @@ const UploadButton = () => {
|
|||
formData
|
||||
);
|
||||
setLoading(false);
|
||||
navigate(pathStabilityScreen)
|
||||
}
|
||||
};
|
||||
return isLoading ? (
|
||||
|
|
|
@ -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<IStability[] | null>(null);
|
||||
React.useEffect(() => {
|
||||
const stabilityCheck = async () => {
|
||||
const result = await HttpRepository.jsonRequest<Array<string>>(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<Array<string>>(HttpMethod.GET, '/' + id + '/generation/stability/' + stabilitySubId + '/geometry.json'))
|
||||
}
|
||||
const stabilityCheck = await (await Promise.allSettled(promises)).map<IStability>((element, index) => {
|
||||
return {
|
||||
status: element.status === 'fulfilled' ? true : false,
|
||||
detail: result[index],
|
||||
}
|
||||
})
|
||||
setStability(stabilityCheck)
|
||||
};
|
||||
stabilityCheck()
|
||||
}, []);
|
||||
return (<div>
|
||||
{stabilityResult != null ? (<>
|
||||
{stabilityResult.map((el, index) => {
|
||||
return (<div><div>{el.detail}</div> <div>{el.status ? (<>Sucses</>) : (<><Button onClick={async () => {
|
||||
await HttpRepository.jsonRequest(HttpMethod.POST, '/assembly/stability/write/computed', {
|
||||
"id": id,
|
||||
"buildNumber": (index + 1).toString()
|
||||
})
|
||||
}}>need input </Button></>)}</div> </div>)
|
||||
})}
|
||||
|
||||
</>) : (<div>loading</div>)}
|
||||
|
||||
</div>);
|
||||
};
|
||||
|
||||
|
|
@ -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<IAdjaxMatrix | null>(null);
|
||||
const param = useParams().id
|
||||
React.useEffect(() => {
|
||||
async function fetchData() {
|
||||
setMatrix(
|
||||
await HttpRepository.jsonRequest<IAdjaxMatrix>(
|
||||
HttpMethod.GET,
|
||||
'/' + param + '/' + HttpRoute.ajaxMatrix
|
||||
)
|
||||
);
|
||||
}
|
||||
fetchData();
|
||||
}, []);
|
||||
return (<div>
|
||||
{matrix === null ? (<>loaded</>) : (<>
|
||||
{matrix.matrixError != null ? (<>
|
||||
{Object.keys(matrix.matrixError).map((keyName, i) => {
|
||||
const m = matrix.matrixError as StringMap;
|
||||
return (
|
||||
<div key={i}>
|
||||
<div>{m[keyName]}</div>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</>) : (<>Success</>)}
|
||||
</>)}
|
||||
|
||||
</div>);
|
||||
};
|
||||
|
||||
|
|
@ -15,6 +15,8 @@ import {
|
|||
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");
|
||||
|
||||
|
@ -35,5 +37,14 @@ const router = createBrowserRouter([
|
|||
path: AssemblyPreviewInsertVectorPath + ":id",
|
||||
element: <AssemblyPreviewInsertVector />,
|
||||
},
|
||||
{
|
||||
path: pathAjaxTopologyScreen + ":id",
|
||||
element:<MatrixTopologyAdjaxScreen/>
|
||||
},
|
||||
{
|
||||
path: pathStabilityScreen + ':id',
|
||||
element:<StabilityPreviewScreen/>
|
||||
}
|
||||
]);
|
||||
|
||||
render(<RouterProvider router={router} />, rootElement);
|
||||
|
|
|
@ -5095,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"
|
||||
|
|
|
@ -52,5 +52,5 @@ if __name__ == "__main__":
|
|||
outPath=args.outPath
|
||||
)
|
||||
StabilityCheckUseCase().call(
|
||||
args.outPath
|
||||
args.outPath
|
||||
)
|
||||
|
|
1
cad_generation/.gitignore
vendored
Normal file
1
cad_generation/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
env.json
|
14
cad_generation/helper/fs.py
Normal file
14
cad_generation/helper/fs.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
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', )
|
||||
|
||||
f.write(data)
|
18
cad_generation/helper/is_solid.py
Normal file
18
cad_generation/helper/is_solid.py
Normal file
|
@ -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
|
19
cad_generation/main.py
Normal file
19
cad_generation/main.py
Normal file
|
@ -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()
|
13
cad_generation/model/files_generator.py
Normal file
13
cad_generation/model/files_generator.py
Normal file
|
@ -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'
|
86
cad_generation/model/geometry_part.py
Normal file
86
cad_generation/model/geometry_part.py
Normal file
|
@ -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)
|
33
cad_generation/model/join_mesh_model.py
Normal file
33
cad_generation/model/join_mesh_model.py
Normal file
|
@ -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)
|
32
cad_generation/model/mesh_part_model.py
Normal file
32
cad_generation/model/mesh_part_model.py
Normal file
|
@ -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)
|
107
cad_generation/model/sdf_geometry_model.py
Normal file
107
cad_generation/model/sdf_geometry_model.py
Normal file
|
@ -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('\'', '"')
|
||||
|
||||
|
30
cad_generation/model/simple_copy_part_model.py
Normal file
30
cad_generation/model/simple_copy_part_model.py
Normal file
|
@ -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)
|
|
@ -0,0 +1,56 @@
|
|||
|
||||
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',)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
53
cad_generation/usecases/asm4parser_usecase.py
Normal file
53
cad_generation/usecases/asm4parser_usecase.py
Normal file
|
@ -0,0 +1,53 @@
|
|||
import FreeCAD as App
|
||||
|
||||
class Asm4StructureParseUseCase:
|
||||
_parts = []
|
||||
_label = []
|
||||
|
||||
def getSubPartsLabel(self, group):
|
||||
groupLabel = []
|
||||
for el in group:
|
||||
if str(el) == '<Part::PartFeature>':
|
||||
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) == '<App::Link object>':
|
||||
groupParts.append(el)
|
||||
|
||||
for el in groupParts:
|
||||
if str(el) == '<App::Link object>':
|
||||
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) == '<App::Link object>':
|
||||
self._label.append({
|
||||
"level": 1,
|
||||
"attachedTo": parent.AttachedTo.split('#'),
|
||||
"label": parent.Label,
|
||||
"axis": self.getSubPartsLabel(parent.Group)
|
||||
})
|
||||
print(self._label)
|
||||
|
||||
|
||||
|
58
cad_generation/usecases/assembly_parse_usecase.py
Normal file
58
cad_generation/usecases/assembly_parse_usecase.py
Normal file
|
@ -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
|
92
cad_generation/usecases/export_assembly_them_all_usecase.py
Normal file
92
cad_generation/usecases/export_assembly_them_all_usecase.py
Normal file
|
@ -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
|
||||
|
||||
|
36
cad_generation/usecases/export_usecase.py
Normal file
36
cad_generation/usecases/export_usecase.py
Normal file
|
@ -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
|
58
cad_generation/usecases/geometry_usecase.py
Normal file
58
cad_generation/usecases/geometry_usecase.py
Normal file
|
@ -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}
|
81
cad_generation/usecases/get_sdf_geometry_usecase.py
Normal file
81
cad_generation/usecases/get_sdf_geometry_usecase.py
Normal file
|
@ -0,0 +1,81 @@
|
|||
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) == '<App::MaterialObjectPython object>':
|
||||
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):
|
||||
for prop in self.PartPropertyCheck:
|
||||
if prop in el:
|
||||
App.Console.PrintMessage(el.Label + ' ' + 'Dont exists property: ' + prop)
|
||||
return
|
||||
for prop in self.ShapePropertyCheck:
|
||||
if prop in el.Shape:
|
||||
App.Console.PrintMessage(el.Label + ' ' + 'Dont exists property: ' + prop)
|
||||
return
|
||||
# com = el.Shape.CenterOfMass or el.Shape.CenterOfGravity
|
||||
# if "Shape" in el:
|
||||
# App.Console.PrintMessage(el.Label + ' ' + 'Dont exists Shape')
|
||||
# return
|
||||
# if "Mass" in el.Shape:
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
|
1
cad_stability_input
Submodule
1
cad_stability_input
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 821cd287ef30fd6a0ba7cb420b6b7e6ff1b91577
|
|
@ -18,7 +18,7 @@ import shutil
|
|||
class RobossemblerFreeCadExportScenario:
|
||||
|
||||
def call(self):
|
||||
|
||||
|
||||
path = self.qtGuiFeature()
|
||||
if path == None:
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue