瀏覽代碼

判断能否一字摆放

duh 7 年之前
父節點
當前提交
9350838f8f
共有 4 個文件被更改,包括 41 次插入10 次删除
  1. 2 2
      phxb/utils/GetAllModule.py
  2. 7 0
      phxb/utils/conf.py
  3. 2 2
      phxb/utils/getarray.py
  4. 30 6
      phxb/utils/matchWall.py

+ 2 - 2
phxb/utils/GetAllModule.py

@@ -21,9 +21,9 @@ def moveBlockReference():
     # print(blockReference.name)
     if(blockReference.name == names[3]):
       insertionPoint = blockReference.InsertionPoint
-      # blockReference.rotate(APoint(insertionPoint[0],insertionPoint[1]),0.5*math.pi)
+      blockReference.rotate(APoint(insertionPoint[0],insertionPoint[1]),-0.5*math.pi)
       print(insertionPoint)
-      blockReference.move(APoint(insertionPoint[0],insertionPoint[1]),APoint(0,0))
+      # blockReference.move(APoint(insertionPoint[0],insertionPoint[1]),APoint(0,0))
 # printObjects()
 # printTheTypeObject("BlockReference")
 

+ 7 - 0
phxb/utils/conf.py

@@ -0,0 +1,7 @@
+# 模块名称
+names=['md_py','md_xs','md_rc']
+# 房间下右上左墙的边长
+roomLengths = (2000,2200,3000,1200)
+roomUsedLengths = (0,0,0,0)
+# 模块长度
+moduleLengths = (800,900,900)

+ 2 - 2
phxb/utils/getarray.py

@@ -78,7 +78,7 @@ def getitemIndexArrayNumber(itemIndex,m,n):
 # result = changeInt2Str(14,3);
 # print(result)
 # getAllArray(4,3)
-# getitemIndexArray("51243",5)
+getitemIndexArray("01243",5,5)
 # number = getitemIndexArrayNumber("51243",5)
 # print(number)
-getAllArrayNumber(4,2)
+# getAllArrayNumber(4,2)

+ 30 - 6
phxb/utils/matchWall.py

@@ -1,11 +1,35 @@
+import utils.conf
+import utils.getarray
 # 判断能否摆下组件的贴墙边
-def canMathc(wallLength,moduleLengths):
+from utils import getarray
+
+# 判断当前边能否放下指定模块
+def canMatch(wallLength, moduleLengths):
     moduleTotalLength = 0;
     for item in moduleLengths:
         moduleTotalLength = moduleTotalLength + item
-    if(moduleTotalLength <= wallLength):
-        return 1
+    return (moduleTotalLength <= wallLength)
+# matchResult = canMatch(3,(1,1,2))
+# print(matchResult)
+# 获取当前位置的所有摆法
+def matchWalls(roomLengths, moduleLengths):
+    m = len(roomLengths)
+    n = len(moduleLengths)
+    a=getarray.getAllArray(m,n)
+    canMatchTop = canMatch(roomLengths[2], moduleLengths)
+    if(canMatchTop):
+        print("begin to calc top")
+        matchWall(roomLengths,moduleLengths,"222")
     else:
-        return 0
-matchResult = canMathc(3,(1,1,2))
-print(matchResult)
+        for item in a:
+            matchWall(roomLengths,moduleLengths,a[item])
+
+def matchWall(roomLengths, moduleLengths, positions):
+    m = len(roomLengths)
+    n = len(moduleLengths)
+    a = getarray.getitemIndexArray(positions,m,n)
+    pass
+#一字摆法
+def matchTopWall(roomLengths,moduleLengths):
+    matchWalls(roomLengths, moduleLengths, "222")
+matchWalls([1,2,3,4],[1,1,1])