From f57782587b2305a834f2bd8404229813bdeef382 Mon Sep 17 00:00:00 2001 From: Tim Wundenberg Date: Tue, 10 Aug 2021 19:22:32 +0200 Subject: [PATCH] add dynamic loading of point clouds name and visible changes are also passed to potree --- .gitignore | 3 +- .../Controllers/PointCloudInfoController.cs | 5 +- .../PointCloudWeb.Server/Globals.cs | 2 +- .../Services/PointCloudService.cs | 16 +- .../PointCloudWeb.Server/Startup.cs | 13 +- PointCloudWeb.Web/.gitignore | 2 + PointCloudWeb.Web/package-lock.json | 90 +---------- .../public/Potree/build/potree/potree.js | 3 +- .../public/Potree/examples/pcw.html | 141 ++++++------------ .../src/components/PotreeViewer.vue | 59 ++++++++ PointCloudWeb.Web/src/components/ScanItem.vue | 4 + .../src/store/pointCloudInfo/store.js | 15 +- PointCloudWeb.Web/src/views/Map.vue | 19 ++- 13 files changed, 157 insertions(+), 215 deletions(-) create mode 100644 PointCloudWeb.Web/src/components/PotreeViewer.vue diff --git a/.gitignore b/.gitignore index fe28d4d..1a9a727 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ obj/ .vscode/ node_modules/ *.csproj.user -.idea \ No newline at end of file +.idea +/temp/ \ No newline at end of file diff --git a/PointCloudWeb.Server/PointCloudWeb.Server/Controllers/PointCloudInfoController.cs b/PointCloudWeb.Server/PointCloudWeb.Server/Controllers/PointCloudInfoController.cs index 552c98a..121bf94 100644 --- a/PointCloudWeb.Server/PointCloudWeb.Server/Controllers/PointCloudInfoController.cs +++ b/PointCloudWeb.Server/PointCloudWeb.Server/Controllers/PointCloudInfoController.cs @@ -14,7 +14,7 @@ namespace PointCloudWeb.Server.Controllers public PointCloudInfoController(PointCloudService pointCloudService) { - this._pointCloudService = pointCloudService; + _pointCloudService = pointCloudService; } private PointCloudInfoDto ConvertPointCloudToDto(PointCloud pc) => new PointCloudInfoDto(pc.Id, pc.Name); @@ -47,7 +47,8 @@ namespace PointCloudWeb.Server.Controllers return new NotFoundResult(); _pointCloudService.RemoveById(id); - return new OkResult(); + //Json Result, becaus OkResult throws in Firefox an XML-Root element not found error. + return new JsonResult("OK"); } [HttpPut] diff --git a/PointCloudWeb.Server/PointCloudWeb.Server/Globals.cs b/PointCloudWeb.Server/PointCloudWeb.Server/Globals.cs index d9df201..0e3bbbb 100644 --- a/PointCloudWeb.Server/PointCloudWeb.Server/Globals.cs +++ b/PointCloudWeb.Server/PointCloudWeb.Server/Globals.cs @@ -7,7 +7,7 @@ namespace PointCloudWeb.Server static Globals() { var basePath = Directory.GetCurrentDirectory() + "/../.."; - PotreeDataPath = basePath + "/PointCloudWeb.Web/public/Potree/pointclouds"; + PotreeDataPath = basePath + "/PointCloudWeb.Web/public/Potree/pointclouds/generated"; PotreeConverterExe = basePath + "/PointCloudWeb.Server/Tools/PotreeConverter/PotreeConverter.exe"; TempPath = basePath + "/temp"; CloudCompareExe = "C:/Program Files/CloudCompare/CloudCompare.exe"; diff --git a/PointCloudWeb.Server/PointCloudWeb.Server/Services/PointCloudService.cs b/PointCloudWeb.Server/PointCloudWeb.Server/Services/PointCloudService.cs index cc9ab2c..abc34d5 100644 --- a/PointCloudWeb.Server/PointCloudWeb.Server/Services/PointCloudService.cs +++ b/PointCloudWeb.Server/PointCloudWeb.Server/Services/PointCloudService.cs @@ -21,23 +21,19 @@ namespace PointCloudWeb.Server.Services private void GeneratePotreeData(Guid id) { - var pathTarget = Globals.PotreeDataPath; - var converter = Globals.PotreeConverterExe; - + var pathTarget = Globals.PotreeDataPath + $"/{id.ToString()}"; var tempFile = Globals.TempPath + $"/{id}.las"; - - Directory.CreateDirectory(Globals.TempPath); - + var pc = _pointClouds.GetById(id); - pc.WriteToLas(tempFile); - - + var potreeConverter = new Process(); potreeConverter.StartInfo.FileName = Globals.PotreeConverterExe; potreeConverter.StartInfo.Arguments = $"\"{tempFile}\" -o \"{Globals.TempPath}/{id.ToString()}\""; potreeConverter.Start(); potreeConverter.WaitForExit(); + + Directory.Move(Globals.TempPath + "/" + id, pathTarget); } private void InitSampleData() @@ -70,7 +66,7 @@ namespace PointCloudWeb.Server.Services public IEnumerable GetAll() => _pointClouds; - public PointCloud GetById(Guid id) => _pointClouds.GetById(id); + public PointCloud GetById(Guid id) => _pointClouds.GetById(id); public void RegisterPointCloud(Guid id) { diff --git a/PointCloudWeb.Server/PointCloudWeb.Server/Startup.cs b/PointCloudWeb.Server/PointCloudWeb.Server/Startup.cs index f2643c5..b71a987 100644 --- a/PointCloudWeb.Server/PointCloudWeb.Server/Startup.cs +++ b/PointCloudWeb.Server/PointCloudWeb.Server/Startup.cs @@ -13,7 +13,13 @@ namespace PointCloudWeb.Server public Startup(IConfiguration configuration) { Configuration = configuration; - Directory.Delete(Globals.TempPath, true); + + if (Directory.Exists(Globals.TempPath)) + Directory.Delete(Globals.TempPath, true); + if (Directory.Exists(Globals.PotreeDataPath)) + Directory.Delete(Globals.PotreeDataPath, true); + Directory.CreateDirectory(Globals.TempPath); + Directory.CreateDirectory(Globals.PotreeDataPath); } public IConfiguration Configuration { get; } @@ -36,10 +42,7 @@ namespace PointCloudWeb.Server //app.UseAuthorization(); - app.UseEndpoints(endpoints => - { - endpoints.MapControllers(); - }); + app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); } // This method gets called by the runtime. Use this method to add services to the container. diff --git a/PointCloudWeb.Web/.gitignore b/PointCloudWeb.Web/.gitignore index 403adbc..a2edb76 100644 --- a/PointCloudWeb.Web/.gitignore +++ b/PointCloudWeb.Web/.gitignore @@ -21,3 +21,5 @@ pnpm-debug.log* *.njsproj *.sln *.sw? + +/public/Potree/pointclouds/generated/* diff --git a/PointCloudWeb.Web/package-lock.json b/PointCloudWeb.Web/package-lock.json index f0019f2..04b4142 100644 --- a/PointCloudWeb.Web/package-lock.json +++ b/PointCloudWeb.Web/package-lock.json @@ -1858,9 +1858,9 @@ } }, "vue-loader-v16": { - "version": "npm:vue-loader@16.4.0", - "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.4.0.tgz", - "integrity": "sha512-oySoEgEedGw0jz2czEOdb6sycQ2PPyzUmF8Yclj1NTpoTVHGCYCQaGf+jsvxhdDVfhOnDLjkRzT2fLpGOrVPjg==", + "version": "npm:vue-loader@16.5.0", + "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.5.0.tgz", + "integrity": "sha512-WXh+7AgFxGTgb5QAkQtFeUcHNIEq3PGVQ8WskY5ZiFbWBkOwcCPRs4w/2tVyTbh2q6TVRlO3xfvIukUtjsu62A==", "dev": true, "optional": true, "requires": { @@ -11366,90 +11366,6 @@ } } }, -<<<<<<< HEAD -======= - "vue-loader-v16": { - "version": "npm:vue-loader@16.4.1", - "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.4.1.tgz", - "integrity": "sha512-nL1bDhfMAZgTVmVkOXQaK/WJa9zFDLM9vKHbh5uGv6HeH1TmZrXMWUEVhUrACT38XPhXM4Awtjj25EvhChEgXw==", - "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" - } - } - } - }, ->>>>>>> a95e821330508d8ec6a5953c53ca70219d0ff815 "vue-router": { "version": "4.0.10", "resolved": "https://registry.nlark.com/vue-router/download/vue-router-4.0.10.tgz", diff --git a/PointCloudWeb.Web/public/Potree/build/potree/potree.js b/PointCloudWeb.Web/public/Potree/build/potree/potree.js index 5849bd1..ea60370 100644 --- a/PointCloudWeb.Web/public/Potree/build/potree/potree.js +++ b/PointCloudWeb.Web/public/Potree/build/potree/potree.js @@ -79571,8 +79571,9 @@ ENDSEC let node = createNode(pcID, pointcloud.name, cloudIcon, pointcloud); pointcloud.addEventListener("visibility_changed", () => { + tree.jstree('rename_node', node, pointcloud.name); if(pointcloud.visible){ - tree.jstree('check_node', node); + tree.jstree('check_node', node); }else { tree.jstree('uncheck_node', node); } diff --git a/PointCloudWeb.Web/public/Potree/examples/pcw.html b/PointCloudWeb.Web/public/Potree/examples/pcw.html index 7cefc14..d41b9b2 100644 --- a/PointCloudWeb.Web/public/Potree/examples/pcw.html +++ b/PointCloudWeb.Web/public/Potree/examples/pcw.html @@ -19,7 +19,6 @@ - @@ -33,16 +32,12 @@ -
-
+
+
- diff --git a/PointCloudWeb.Web/src/components/PotreeViewer.vue b/PointCloudWeb.Web/src/components/PotreeViewer.vue new file mode 100644 index 0000000..49dfe66 --- /dev/null +++ b/PointCloudWeb.Web/src/components/PotreeViewer.vue @@ -0,0 +1,59 @@ + + + + + \ No newline at end of file diff --git a/PointCloudWeb.Web/src/components/ScanItem.vue b/PointCloudWeb.Web/src/components/ScanItem.vue index 31de4e2..250bfca 100644 --- a/PointCloudWeb.Web/src/components/ScanItem.vue +++ b/PointCloudWeb.Web/src/components/ScanItem.vue @@ -46,6 +46,10 @@ export default { methods: { onClickVisible() { this.isVisible = !this.isVisible; + this.$store.dispatch("pci/updateVisible", { + id: this.item.id, + visible: this.isVisible, + }); }, onEnter() { this.onClickSave(); diff --git a/PointCloudWeb.Web/src/store/pointCloudInfo/store.js b/PointCloudWeb.Web/src/store/pointCloudInfo/store.js index ae07023..efc4997 100644 --- a/PointCloudWeb.Web/src/store/pointCloudInfo/store.js +++ b/PointCloudWeb.Web/src/store/pointCloudInfo/store.js @@ -8,12 +8,11 @@ export default { pointClouds: [], loading: false }, - // getters: { - // pointClouds: state => state.pointClouds, - // loading: state => state.loading - // }, mutations: { SET_POINT_CLOUDS(state, pointClouds) { + for (const i in pointClouds) { + pointClouds[i].visible = true; + } state.pointClouds = pointClouds }, SET_LOADING(state, loading) { @@ -25,12 +24,17 @@ export default { return; if (pointCloud.action === "update") { + pointCloud.data.visible = true; state.pointClouds[index] = pointCloud.data; } else if (pointCloud.action === "remove") { state.pointClouds.splice(index, 1); } }, + SET_VISIBLE(state, visibleInfo){ + let pc = state.pointClouds.find(x => x.id === visibleInfo.id); + pc.visible = visibleInfo.visible; + }, }, actions: { loadPointClouds({ commit }) { @@ -68,6 +72,9 @@ export default { alert(e); commit('SET_LOADING', false); }) + }, + updateVisible({ commit }, visibleInfo) { + commit('SET_VISIBLE', visibleInfo); } } } diff --git a/PointCloudWeb.Web/src/views/Map.vue b/PointCloudWeb.Web/src/views/Map.vue index 9e73942..9d9dd2f 100644 --- a/PointCloudWeb.Web/src/views/Map.vue +++ b/PointCloudWeb.Web/src/views/Map.vue @@ -5,17 +5,20 @@

Point Clouds

    -
  • +
  • + +
-
- +
+