From 8dcc98164d11ccd5483049599a7fdeb68c4dedaa Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Fri, 29 Oct 2021 11:17:40 +0200 Subject: [PATCH] Initial backend+frontend connection + gitignore changes --- .gitignore | 4 + frontend/package-lock.json | 160 +++++++++--------- .../components/commitSelector/CommitPanel.vue | 30 +++- server/__pycache__/main.cpython-39.pyc | Bin 633 -> 0 bytes server/__pycache__/mesh_diff.cpython-39.pyc | Bin 4892 -> 0 bytes server/main.py | 25 ++- server/mesh_diff.py | 49 +++--- 7 files changed, 158 insertions(+), 110 deletions(-) create mode 100644 .gitignore delete mode 100644 server/__pycache__/main.cpython-39.pyc delete mode 100644 server/__pycache__/mesh_diff.cpython-39.pyc diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ef5bea2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ + +.vscode/ + +server/__pycache__/ diff --git a/frontend/package-lock.json b/frontend/package-lock.json index b396f40..ba90110 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1744,16 +1744,6 @@ "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", "dev": true }, - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "optional": true, - "requires": { - "color-convert": "^2.0.1" - } - }, "cacache": { "version": "13.0.1", "resolved": "https://registry.npmjs.org/cacache/-/cacache-13.0.1.tgz", @@ -1780,34 +1770,6 @@ "unique-filename": "^1.1.1" } }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "optional": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "optional": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true, - "optional": true - }, "fs-extra": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", @@ -1819,25 +1781,6 @@ "universalify": "^0.1.0" } }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "optional": true - }, - "loader-utils": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz", - "integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==", - "dev": true, - "optional": true, - "requires": { - "big.js": "^5.2.2", - "emojis-list": "^3.0.0", - "json5": "^2.1.2" - } - }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -1854,16 +1797,6 @@ "minipass": "^3.1.1" } }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "optional": true, - "requires": { - "has-flag": "^4.0.0" - } - }, "terser-webpack-plugin": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-2.3.8.tgz", @@ -1880,18 +1813,6 @@ "terser": "^4.6.12", "webpack-sources": "^1.4.3" } - }, - "vue-loader-v16": { - "version": "npm:vue-loader@16.8.2", - "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.8.2.tgz", - "integrity": "sha512-Nkq+z9mAsMEK+qkXgK+9Ia7D8w9uu9j4ut0IMT5coMfux3rCgIp1QBB1CYwY0M34A1nRMSONEaWXxAAw6xSl/Q==", - "dev": true, - "optional": true, - "requires": { - "chalk": "^4.1.0", - "hash-sum": "^2.0.0", - "loader-utils": "^2.0.0" - } } } }, @@ -11513,6 +11434,87 @@ } } }, + "vue-loader-v16": { + "version": "npm:vue-loader@16.8.2", + "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.8.2.tgz", + "integrity": "sha512-Nkq+z9mAsMEK+qkXgK+9Ia7D8w9uu9j4ut0IMT5coMfux3rCgIp1QBB1CYwY0M34A1nRMSONEaWXxAAw6xSl/Q==", + "dev": true, + "optional": true, + "requires": { + "chalk": "^4.1.0", + "hash-sum": "^2.0.0", + "loader-utils": "^2.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "optional": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "optional": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "optional": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "optional": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "optional": true + }, + "loader-utils": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz", + "integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==", + "dev": true, + "optional": true, + "requires": { + "big.js": "^5.2.2", + "emojis-list": "^3.0.0", + "json5": "^2.1.2" + } + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "optional": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, "vue-router": { "version": "3.5.1", "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.5.1.tgz", diff --git a/frontend/src/components/commitSelector/CommitPanel.vue b/frontend/src/components/commitSelector/CommitPanel.vue index 7d230de..7bc1a5d 100644 --- a/frontend/src/components/commitSelector/CommitPanel.vue +++ b/frontend/src/components/commitSelector/CommitPanel.vue @@ -84,14 +84,18 @@
You are about to compare commit - + {{ commitA ? commitA.id : "Select commit" }} against - + {{ commitB ? commitB.id : "Select commit" }} - + Run this!
@@ -100,6 +104,8 @@ diff --git a/server/__pycache__/main.cpython-39.pyc b/server/__pycache__/main.cpython-39.pyc deleted file mode 100644 index 885fa0d0843ae67b877a966f99d90f7a75d24548..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 633 zcmYjPy>1&Z3>HuK>)6TMNAMCa9gCtxfFNDm02u-Z1rCBGrvgsCt0V_V;!MtCbZC&t zLtaS8)~TK$bf0SW+K=5pF*YgpfZ);u{DUYzbWu$sH^^fu0AkT{Z7?D?cHUVGf?Fj z8;|~BCpLyye(!>57qUUWIF>$qJ^i+UxIb%cC!MaX_CK|MhRKWoyOLmVgz8H)3RGeM z3-hVSPIS|>B0Fzgqc+SDyRCVy4u4o_7Khzctelprc5NG|hNp@waTVI@j}v9)^T~}5 zm}6_BZYMW5lQp59EuGVgu)XMQ9es54lv_HECXeNX4mAx-sCORZBWk=C^KjLf#f2k+qL|~BWoI0x zsGt$IsB+4O)#F^Mw47Z2NC1-Y* zJwruH^a2LxqXihb+0cOw3RGNxIhn!KR9AOb zcU5&g+AE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o2sP;)|#( zh6BMFYH$HK$YaNLaNzOsBCm1>&O>kh-%du)YAi}R4!W@33_9zQ4n~p*dhK?n+m=-E zBzBBTcO|REmPV@V4;HDHg>lD?n| zC(cHC1)VwG51rtIP#Igqy6*gw-X}I*jPwm&8^WD?GNPxianWMi?}fPT4P=@2Um-wc zkiKY0Dr8YtrFVA7Fq))I>mJ$6A+sJX$TH15ycfwjG16z@HeqiQpxbR?;#3_;W>gsK z`ckJM9fq_iju=%}s`?I@T?%_*H}Ef0nv5s~77-cgMVZYH@gh4(G>!;qQ6X;eau%lk QPq9> SpeckleClient: - client = SpeckleClient(host=HOST) - account = get_default_account() - client.authenticate(token=account.token) +def get_authenticated_client(token: str) -> SpeckleClient: + client = SpeckleClient(host=HOST) + client.authenticate(token=token) return client + def receive_data( client: SpeckleClient, stream_id: str, commit_id: str ) -> Any: @@ -45,7 +43,8 @@ def receive_data( return res -def get_all_meshes(child:Base): + +def get_all_meshes(child: Base): meshes = [] names = child.get_dynamic_member_names() @@ -58,7 +57,7 @@ def get_all_meshes(child:Base): if not hasattr(prop, "displayMesh"): break meshes.append((prop.displayMesh, prop.id)) - elif isinstance(prop, list): + elif isinstance(prop, list): for p in prop: if isinstance(p, Mesh): meshes.append((p, p.id)) @@ -68,6 +67,7 @@ def get_all_meshes(child:Base): meshes.append((p.displayMesh, p.id)) return meshes + def get_all_points(meshes: List[Mesh]): points = [] for mesh in meshes: @@ -79,16 +79,19 @@ def get_all_points(meshes: List[Mesh]): points.append(point) return points + def find_point(current: Point, points: List[Point]): for point in points: if (point.x == current.x and point.y == current.y and point.z == current.z): return True return False + def find_closest_point(current: Point, points: List[Point]): smallest_distance = None for point in points: - d = ((current.x - point.x)**2 + (current.y - point.y)**2 + (current.z - point.z)**2)**0.5 + d = ((current.x - point.x)**2 + (current.y - point.y) + ** 2 + (current.z - point.z)**2)**0.5 if smallest_distance is not None: if d > smallest_distance: continue @@ -96,12 +99,12 @@ def find_closest_point(current: Point, points: List[Point]): return smallest_distance -def compare_meshes(stream_id: str, commit_current: str, commit_previous: str): - client = get_authenticated_client() +def compare_meshes(stream_id: str, commit_current: str, commit_previous: str, token: str): + client = get_authenticated_client(token) # see if existing diff commit already exists # query for latest x commits in diff branch - # read commit message & parse + # read commit message & parse # return url if found # get meshes from commits @@ -152,7 +155,7 @@ def compare_meshes(stream_id: str, commit_current: str, commit_previous: str): diff_values = [] for vertex in vertices: diff_values.append(find_closest_point(vertex, previous_points)) - + # determine color value for vertex by remapping domain bin_size = max(diff_values) / len(COLORS) for i in range(0, len(vertices), 1): @@ -175,11 +178,10 @@ def compare_meshes(stream_id: str, commit_current: str, commit_previous: str): prev_meshes.append(mesh) # create a new commit with the diff meshes and changed edges - return send_diff_data(stream_id, commit_current, commit_previous, diff_meshes, match_meshes, prev_meshes) + return send_diff_data(stream_id, commit_current, commit_previous, diff_meshes, match_meshes, prev_meshes, client) -def send_diff_data(stream_id: str, commit_current: str, commit_previous: str, meshes: List[Mesh], unchanged: List[Mesh], prev: List[Mesh]): - client = get_authenticated_client() +def send_diff_data(stream_id: str, commit_current: str, commit_previous: str, meshes: List[Mesh], unchanged: List[Mesh], prev: List[Mesh], client): # create a branch if necessary branches = client.branch.list(stream_id) @@ -201,12 +203,9 @@ def send_diff_data(stream_id: str, commit_current: str, commit_previous: str, me commit_id = client.commit.create( stream_id, - hash, # object id + hash, # object id DIFF_BRANCH, - message= commit_current + "-" + commit_previous + message=commit_current + "-" + commit_previous ) - return 'https://speckle.xyz/streams/' + stream_id + '/commits/' + commit_id - - - + return f'https://{HOST}/streams/' + stream_id + '/commits/' + commit_id