コード例 #1
0
ファイル: rl_test.py プロジェクト: seanys/Learn-to-Pack
 def getDrease(self, criteria):
     poly_list = []
     for poly in self.polys:
         if criteria == 'length':
             left, bottom, right, top = GeoFunc.checkBoundValue(poly)
             poly_list.append([poly, right - left])
         elif criteria == 'height':
             left, bottom, right, top = GeoFunc.checkBoundValue(poly)
             poly_list.append([poly, top - bottom])
         else:
             poly_list.append([poly, Polygon(poly).area])
     poly_list = sorted(poly_list, key=lambda item: item[1],
                        reverse=True)  # 排序,包含index
     dec_polys = []
     for item in poly_list:
         dec_polys.append(item)
     return dec_polys
コード例 #2
0
ファイル: heuristic.py プロジェクト: seanys/Learn-to-Pack
 def updateBound(self):
     '''
     更新包络长方形
     '''
     border_left, border_bottom, border_right, border_top = GeoFunc.checkBoundValue(
         self.cur_polys[-1])
     if border_left < self.border_left:
         self.border_left = border_left
     if border_bottom < self.border_bottom:
         self.border_bottom = border_bottom
     if border_right > self.border_right:
         self.border_right = border_right
     if border_top > self.border_top:
         self.border_top = border_top
     self.border_height = self.border_top - self.border_bottom
     self.border_width = self.border_right - self.border_left