Selaa lähdekoodia

修改业务空间引擎版本;增加吸附;创建业务空间时与已创建的取差集

haojianlong 5 vuotta sitten
vanhempi
commit
18953720e2
2 muutettua tiedostoa jossa 83 lisäystä ja 81 poistoa
  1. 1 1
      package.json
  2. 82 80
      src/components/business_space/newGraphy/graphy.vue

+ 1 - 1
package.json

@@ -36,7 +36,7 @@
     "@saga-web/base": "2.1.9",
     "@saga-web/draw": "2.1.61",
     "@saga-web/graphy": "2.1.34",
-    "@saga-web/cad-engine": "2.0.432"
+    "@saga-web/cad-engine": "2.0.458"
   },
   "devDependencies": {
     "ajv": "^6.9.1",

+ 82 - 80
src/components/business_space/newGraphy/graphy.vue

@@ -108,7 +108,6 @@ import {
   groupCreRelaZoneAndISp
 } from "@/api/scan/request"
 
-//  BSP => 业务空间
 export default {
   components: {
     canvasFun,
@@ -148,12 +147,13 @@ export default {
       groupCreateDialogVis: false, //批量创建业务空间弹窗
       groupCreateType: 1, //批量创建方式
       zoneDisable: true, // 重新划分是否禁用
+      sourceIdToISP: {}
     }
   },
   computed: {
     ...mapGetters('layout', ['projectId'])
   },
-  created() {},
+  created() { },
   mounted() {
     this.canvasWidth = this.$refs.graphy.offsetWidth;
     this.canvasHeight = this.$refs.graphy.offsetHeight;
@@ -205,9 +205,12 @@ export default {
       queryZone(pa, res => {
         this.BIMIDToSID = {}
         this.BIMIDToSIName = {}
+        this.sourceIdToISP = {}
         res.Content.map(t => {
-          this.BIMIDToSID[t.BIMID.split(":")[1]] = t.RoomID;
-          this.BIMIDToSIName[t.BIMID.split(":")[1]] = t.RoomLocalName || t.RoomName;
+          let key = t.BIMID.split(":")[1];
+          this.BIMIDToSID[key] = t.RoomID;
+          this.BIMIDToSIName[key] = t.RoomLocalName || t.RoomName;
+          this.sourceIdToISP[key] = t;
         })
       })
     },
@@ -474,31 +477,32 @@ export default {
     },
     // 根据图创建新的业务空间-弹窗返回确认创建
     createRoom(val) {
-      let zoneObj = { Outline: [], Height: 0 }, IspaceIdList = [];
-      let selectSpaces = this.scene.getSelectedSpaces();
-      selectSpaces.map(t => {
-        zoneObj.Outline.push(t.data.OutLine);
-        if (this.BIMIDToSID[t.data.SourceId]) {
-          IspaceIdList.push(this.BIMIDToSID[t.data.SourceId]);
-        }
-        if (t.data.Height && (zoneObj.Height == 0 || t.data.Height < zoneObj.Height)) {
-          zoneObj.Height = t.data.Height > 100 ? (t.data.Height / 1000).toFixed(2) : t.data.Height;
-        }
-      })
-      // 如果有划分,求交集
+      const zoneObj = { Outline: [], Height: 0 }, IspaceIdList = [];
+      let spaces = {};
       if (this.scene.cutItem || this.scene.sceneMark) {
-        zoneObj.Outline = [];
-        let arr = this.scene.getIntersect();
-        arr.map(t => {
+        // 如果有划分,求交集
+        // 格式为Poly(先与业务空间求差集)
+        const obj = this.scene.getZoneDifference(true);
+        // 差集与楼层平面图或用户划分区域求交集
+        spaces = this.scene.getPloyIntersect(obj)
+      } else {
+        // 格式为SPoint[]
+        spaces = this.scene.getZoneDifference();
+      }
+      for (let key in spaces) {
+        spaces[key].map(t => {
           let temp = t.map(item => {
             return {
-              X: item.x,
-              Y: -item.y,
+              X: 1*item.x.toFixed(2),
+              Y: -item.y.toFixed(2),
               Z: 0
             }
           })
           zoneObj.Outline.push([temp]);
         })
+        let curISP = this.sourceIdToISP[key];
+        curISP && IspaceIdList.push(curISP.RoomID);
+        zoneObj.Height = zoneObj.Height == 0 ? curISP.Height : zoneObj.Height > curISP.Height ? curISP.Height : zoneObj.Height;
       }
       if (!zoneObj.Outline.length) {
         zoneObj.Outline = null;
@@ -509,38 +513,39 @@ export default {
       this.createSingleBSP(zoneObj, IspaceIdList)
     },
     // 根据图从未关联平面图的业务空间中选择--按钮返回关联信号
-    createFromUnrelated(BSP) {
-      BSP.Outline = [];
-      BSP.Height = 0;
-      let arr = this.scene.getSelectedSpaces(), IspaceIdList = [];
-      arr.map(t => {
-        BSP.Outline.push(t.data.OutLine);
-        if (this.BIMIDToSID[t.data.SourceId]) {
-          IspaceIdList.push(this.BIMIDToSID[t.data.SourceId]);
-        }
-        if (t.Height && (BSP.Height == 0 || t.Height < BSP.Height)) {
-          BSP.Height = t.Height > 100 ? (t.Height / 1000).toFixed(2) : t.Height;
-        }
-      })
-      // 如果有划分,求交集
+    createFromUnrelated(zoneObj) {
+      zoneObj.Outline = [];
+      zoneObj.Height = 0;
+      let spaces = {}, IspaceIdList = [];
       if (this.scene.cutItem || this.scene.sceneMark) {
-        BSP.Outline = [];
-        let spaceIntersect = this.scene.getIntersect();
-        spaceIntersect.map(t => {
+        // 如果有划分,求交集
+        // 格式为Poly(先与业务空间求差集)
+        const obj = this.scene.getZoneDifference(true);
+        // 差集与楼层平面图或用户划分区域求交集
+        spaces = this.scene.getPloyIntersect(obj)
+      } else {
+        // 格式为SPoint[]
+        spaces = this.scene.getZoneDifference();
+      }
+      for (let key in spaces) {
+        spaces[key].map(t => {
           let temp = t.map(item => {
             return {
-              X: item.x,
-              Y: -item.y,
+              X: 1*item.x.toFixed(2),
+              Y: -item.y.toFixed(2),
               Z: 0
             }
           })
-          BSP.Outline.push([temp]);
+          zoneObj.Outline.push([temp]);
         })
+        let curISP = this.sourceIdToISP[key];
+        curISP && IspaceIdList.push(curISP.RoomID);
+        zoneObj.Height = zoneObj.Height == 0 ? curISP.Height : zoneObj.Height > curISP.Height ? curISP.Height : zoneObj.Height;
       }
-      if (!BSP.Outline.length) {
-        BSP.Outline = null;
+      if (!zoneObj.Outline.length) {
+        zoneObj.Outline = null;
       }
-      this.updateBSPOutline(BSP, IspaceIdList)
+      this.updateBSPOutline(zoneObj, IspaceIdList)
     },
     // 编辑空间详情
     editeSpaceDetail() {
@@ -625,46 +630,43 @@ export default {
     // 根据图批量创建所选业务空间
     groupCreateZone() {
       let arr = this.scene.getSelectedSpaces();
-      let spaces = [];
-      // 如果有划分,求交集
+      let createSpaces = [], spaces = {};
       if (this.scene.cutItem || this.scene.sceneMark) {
-        let outlines = this.scene.getIntersectInSpace();
-        for (let k in outlines) {
-          outlines[k] = outlines[k].map(t => {
-            t = t.map(item => {
-              item = item.map(j => {
-                return { X: j.x, Y: -j.y, Z: 0 }
-              })
-              return item
-            })
-            return t;
-          })
-        }
-        spaces = arr.map(t => {
-          return {
-            IspaceId: this.BIMIDToSID[t.data.SourceId],
-            RoomLocalName: this.BIMIDToSIName[t.data.SourceId],
-            Outline: outlines[t.data.SourceId],
-            BuildingId: this.buildFloor[0],
-            FloorId: this.buildFloor[1],
-            Height: t.data.Height > 100 ? (t.data.Height / 1000).toFixed(2) : t.data.Height || 0
-          }
-        }).filter(item => item.Outline && item.Outline.length)
+        // 如果有划分,求交集
+        // 格式为Poly(先与业务空间求差集)
+        const obj = this.scene.getZoneDifference(true);
+        // 差集与楼层平面图或用户划分区域求交集
+        spaces = this.scene.getPloyIntersect(obj)
       } else {
-        spaces = arr.map(t => {
-          return {
-            IspaceId: this.BIMIDToSID[t.data.SourceId],
-            RoomLocalName: this.BIMIDToSIName[t.data.SourceId],
-            Outline: [t.data.OutLine],
-            BuildingId: this.buildFloor[0],
-            FloorId: this.buildFloor[1],
-            Height: t.data.Height > 100 ? (t.data.Height / 1000).toFixed(2) : t.data.Height || 0
-          }
-        })
+        // 格式为SPoint[]
+        spaces = this.scene.getZoneDifference();
       }
-      if (spaces.length) {
+      for (let key in spaces) {
+        let zoneObj = { Outline: [], Height: 0 }
+        spaces[key].map(t => {
+          let temp = t.map(item => {
+            return {
+              X: 1*item.x.toFixed(2),
+              Y: -item.y.toFixed(2),
+              Z: 0
+            }
+          })
+          zoneObj.Outline.push([temp]);
+        })
+        if (!zoneObj.Outline.length) {
+          continue
+        }
+        let curISP = this.sourceIdToISP[key];
+        zoneObj.Height = zoneObj.Height == 0 ? curISP.Height : zoneObj.Height > curISP.Height ? curISP.Height : zoneObj.Height;
+        zoneObj.IspaceId = curISP.RoomID;
+        zoneObj.RoomLocalName = curISP.RoomLocalName;
+        zoneObj.BuildingId = this.buildFloor[0];
+        zoneObj.FloorId = this.buildFloor[1];
+        createSpaces.push(zoneObj);
+      }
+      if (createSpaces.length) {
         this.canvasLoading = true;
-        this.groupCreateBSP(spaces)
+        this.groupCreateBSP(createSpaces)
       } else {
         this.$message.warning('未选择本层空间');
       }