Explorar o código

优化了一下

xushiting %!s(int64=4) %!d(string=hai) anos
pai
achega
0270619d44
Modificáronse 1 ficheiros con 12 adicións e 9 borrados
  1. 12 9
      src/CAD/core/additional/calcRoom.js

+ 12 - 9
src/CAD/core/additional/calcRoom.js

@@ -25,27 +25,30 @@ export default function calcRoom(data, cad) {
   //wallIds里的元素有三个属性:id,p1,p2,p1和p2对应的是墙端点的id
   function getAllRooms(wallIds) {
     for (let i = 0; i < wallIds.length; ++i) {
-      let exceptWalls = [];
+      //let exceptWalls = [];
       let exceptPoints = [];
       let ringPoints = [];   //存放的是顶点
       let ringWalls = [];   //存放的是墙面
-      for (let k = 0; k <= i; ++k) {
-        exceptWalls.push(k);
-      }
+      //for (let k = 0; k <= i; ++k) {
+        //exceptWalls.push(k);
+      //}
       let wall1 = wallIds[i];
       let startPointId = wall1.p1.id;
       let endPointId = wall1.p2.id;
       ringPoints.push(endPointId);
       ringWalls.push(wall1.id);
       let currentPointId = null;
-      for (let j = i + 1; j < wallIds.length; ++j) {
+	  wallIds.splice(i,1);
+      //for (let j = i + 1; j < wallIds.length; ++j) {
+      for (let j = 0; j < wallIds.length; ++j) {
         let wall2 = wallIds[j];
         if (startPointId == wall2.p1.id || startPointId == wall2.p2.id) {
           //相连
           let _ringPoints = JSON.parse(JSON.stringify(ringPoints));
           let _ringWalls = JSON.parse(JSON.stringify(ringWalls));
-          let _exceptWalls = JSON.parse(JSON.stringify(exceptWalls));
-          let _exceptPoints = JSON.parse(JSON.stringify(exceptPoints));
+          //let _exceptWalls = JSON.parse(JSON.stringify(exceptWalls));
+          let _exceptWalls = [];
+		  let _exceptPoints = JSON.parse(JSON.stringify(exceptPoints));
           let _startPointId = startPointId;
           _ringPoints.push(startPointId);
           _ringWalls.push(wall2.id);
@@ -237,8 +240,8 @@ export default function calcRoom(data, cad) {
     }
   })
 
-
-  getAllRooms(wall)
+  let _wall = JSON.parse(JSON.stringify(wall));
+  getAllRooms(_wall)
   
 
   _roomsPoints = _roomsPoints.map(points => points.map(point => data.vertex.find(({id}) => point === id)))