Browse Source

区域判断修改

duh 6 years ago
parent
commit
058b251dc3
1 changed files with 16 additions and 14 deletions
  1. 16 14
      phxb/utils/GetAllModule.py

+ 16 - 14
phxb/utils/GetAllModule.py

@@ -155,32 +155,34 @@ def tempStoragePosition(x,y,wallIndex,blockIndex):
   result = 1
   for item in positoins:
     # 判断实体是否相交
-    result = isPositionFeasible(positoin,positoins[item])
+    result = isPositionFeasible(positoin,positoins[item],0)
     if(result == 0):
       positoins.clear()
       return result
     else:
       # 判断可用区域是否与实体相交
-      usePoint = positoin[3]
-      positoin[0] = usePoint
-      positoin[1] = positoin[4]
-      result = isPositionFeasible(positoin,positoins[item])
+      usePosition = (positoin[3],positoin[4])
+      result = isPositionFeasible(usePosition,positoins[item],1)
   if(result == 1):
     positoins[len(positoins)] = positoin
   return result
 
-# 计算位置是否可行
-def isPositionFeasible(position1,position2):
-  acad.model.AddLine(APoint(position1[0][0],position1[0][1]),APoint(position2[0][0],position2[0][1]))
-  acad.model.AddCircle(APoint(position1[0][0],position1[0][1]), 50)
-  if(math.ceil(position1[0][0]-position2[0][0]) < (position1[1][0]+position2[1][0])/2):
-    if(math.ceil(position1[0][1]-position2[0][1]) < (position1[1][1]+position2[1][1])/2):
-      print("sorry! can not put here")
+# 计算位置是否可行type:0 实体 1可用区域
+def isPositionFeasible(position1,position2,type):
+  areaName = "可用区域"
+  if type==0:
+    acad.model.AddLine(APoint(position1[0][0],position1[0][1]),APoint(position2[0][0],position2[0][1]))
+    acad.model.AddCircle(APoint(position1[0][0],position1[0][1]), 50)
+    areaName = "实体"
+  if(abs(position1[0][0]-position2[0][0]) < (position1[1][0]+position2[1][0])/2):
+    print(areaName,"begin to check y")
+    if(abs(position1[0][1]-position2[0][1]) < (position1[1][1]+position2[1][1])/2):
+      print(areaName,"sorry! can not put here","position1=",position1,"position2=",position2)
       return 0
-    print("can put here 1")
+    print(areaName,"can put here 1")
     return 1
   else:
-    print("can put here 2")
+    print(areaName,"can put here 2")
     return 1
 # printObjects()
 # printBlockObjects()